FAQ Database Discussion Community


How to pass attribute of one model as a param to a different model?

ruby-on-rails,ruby-on-rails-4,parameter-passing,params
I have a Favorite model and an Article model. The Favorite has an attribute .fav_id that is equal to the the .id of Article. I want to create a link_to @article.title and pass a param of :id=>@favorite.fav_id. favorites controller def show @favorite = Favorite.find(params[:id]) @article = Article.find(params[:id]) end view/favorite/show <%=...

Android Layout Params change ONLY width and height

android,view,params
I know how to set the width and the height of a view using LayoutParams via doing the following: android.view.ViewGroup.LayoutParams params = button.getLayoutParams(); params.width = height/7; params.height = height/10; button.setLayoutParams(params); Now, as soon as I wanna apply the same height and the width to another button, I need to create...

Joomla Get menu id from names

joomla,menu,params
I am in joomla 2.5 and I try to get the id of a menu, I have the name, the alias exemple : menu = FAQ-> menu item =FAQ I have try : $app = JFactory::getApplication('site'); $params = $app->getParams(); $idfaq = $params->get('content_id_faq'); but i am a newbie so I dont...

Ruby on rails : Issue with Params

ruby-on-rails,ruby,params
I'm developing a job board where the companies can submit job ads With jobdescriptions_controller, I also have an uuid field as ID for the outside world called "applyjobid", but now for the outside world I have created jobdetails_controller in order to find the jobdescription. So, when I goto http://localhost:3000/jobdetails/show?applyjobid=54da4118-0ba3-4375-ae87-6fa32201a369 I...

Print index table with prawn ruby on rails

ruby,ruby-on-rails-4,search,params,prawn
I'm having trouble trying to print the array that a search produces in the index of my app. Here is my code: appointments controller (index action): def index @appointments = Appointment.search(params[:search]) respond_to do |format| format.html format.pdf do pdf = AppointmentsPdf.new(@appointments) send_data pdf.render, filename: "citas_del_dia", type: "application/pdf", disposition: "inline" end end...

passing parameters between views and controllers ruby 1.8.7

ruby-on-rails-3,controller,params
i have this form nested in view 'A' <div> <%if current_user%> <%=form_for(ModelB.new) do |f|%> <%if (params[:param_to_check].present?)%> <%f.hidden_field "param1",:value=> @modelA.id%> <%f.hidden_field "param2",:value=> current_user.id%> <%end%> render button <%end%> <%else%> render other butotn <%end%> </div> and this 'find' in Bs_controller: @modelA=ModelA.find_by_id(params[:param1]) :option_from_specific_gem=> -(@modelA.wanted_value).abs when i look to the params...

Nested_attributes dont appear in my params

ruby-on-rails,ruby,forms,nested-forms,params
I try to include nested_form in one on my model new form. <%= form_for :master_box, url: master_boxes_path do |f| %> <%= f.label :number %><br> <%= f.text_field :number %> <%= f.fields_for :orders do |o| %> <fieldset> <%= o.label :number, "Number" %> <%= o.text_field :number %> </fieldset> <% end %> <br> <%=...

Fancybox Youtube params cc_lang_pref not working?

jquery,youtube,fancybox,fancybox-2,params
I'm trying to pass some additional parameters through Fancybox for a video to force the French captions to be shown on an English video. When I include them in the href url, they aren't passed through to the iFrame. When I add : youtube : { params : { autoplay...

How to pass all the devise params to entry_params

ruby-on-rails,devise,params
Rails 4 uses the following function to trust params before allowing them in the database. def entry_params params.require(:entry).permit(:title_of_work, :size, :price, :media) end I'm also using the devise gem and I want to allow all this through too but it doesn't work. For example def entry_params params.require(:entry).permit(:title_of_work, :size, :price, :media, :current_user)...

Yii2: Passing params to breadcrumbs

yii2,params,breadcrumbs
I would like to know there is a proper way of keeping track of URL params in Yii2 breadcrumbs. For instance, if I have something like: Start / BrowsingLevel-1 corresponding to: myroute/index?id=4 then I browse ahead to: Start / BrowsingLevel-1 / BrowsingLevel-2 And then (using breadcrumbs) try to browse back...

Adding user's photo to contest, call method with link_to

ruby-on-rails,params
I came from a JS background so Rails is weird to me. I currently have a show.html.erb for the contest model: <h1>Contest name: <%= @contest.name %></h1> <h2>Contest criteria: <%= @contest.criteria %></h2> <h3>Photos: </h3> <%= link_to "Enter Contest", "#" %> <% @contest.photos.each do |photo| %> <%= image_tag("#{photo}") %> <% end %>...

Execute an shell program with node.js and pass params [closed]

node.js,shell,params
I would like to execute an shell program who require any params with Node.js How can I do that ?...

undefined method `permit' for “51”:String

ruby-on-rails,params
This error is coming when I am updating, I don't know why this error is coming def update1 @user = User.find(params[:user]) if @user.update_attributes(user_params) redirect to user_steps_path else render 'edit1' end end private def user_params params.require(:user).permit(:fname, :lname, :email) end end Parameters: {"utf8"=>"✓", "authenticity_token"=>"wY+llV4qot5xDsxp1JvaltvPdrZND7goaorBTh8Vteo=", "user"=>"51", "commit"=>"Update"} Edit.html.erb This is my edit form...

Angular ui router passing data between states without URL

angularjs,angular-ui-router,state,params
I am facing this problem of passing data between two states without exposing the data in the url, it's like user cannot really directly land on this state. For example. I have two states "A" and "B". I am doing some server call in state "A" and passing the response...

Adding Parameters with Stripe Checkout

ruby-on-rails,object,stripe-payments,params
I am attempting to add parameters to Stripe Checkout. new.html.erb <%= form_for @user do |f| %> <%= f.label :first_name %> <%= f.text_field :first_name %> <%= f.label :last_name %> <%= f.text_field :last_name %> <% end %> <%= form_tag charges_path, class: 'stripeform' do %> <script src="https://checkout.stripe.com/checkout.js" class="stripe-button" data-key="<%= Rails.configuration.stripe[:publishable_key] %>" data-description="Beautiful" data-amount="<%=...

Passing delegates as parameters for mediator/subscriber pattern

c#,events,delegates,params,mediator
I'm looking for the appropriate and elegant way to create Mediator/Subscriber architecture with typed callbacks. Let's suppose I have a class with 'events' i.e. delegates: public class E { public delegate void SomethingHappened (float a, int b); public delegate void ProgressFinished (int[] c); } Now I want to create a...

ruby on rails iterating params

ruby-on-rails,ruby,params
I have a client that is sending params such as age, gender, name and so on. I need to retrieve data from the table based on the params, but first I need to check for the presence of the param(to avoid a null param and therefore an empty result). The...

Passing params without nil

ruby-on-rails,ruby-on-rails-3,ruby-on-rails-4,search,params
I want to pass the value of a form to a Controller that should call a method from the Model for searching products i want to pass category_id and the string that the user writes in the textfield. I would pass to the model even the blank value of params...

Hidden params when using $state not working - AngularJS, Ionic

angularjs,url,state,params,ionic
I'm a beginner using the ionic framework. I'm trying to use stateParams with a state but I don't want it to be exposed in the URL. I could use stateParams when it's added to the URL (url/:param1) but when I tried to declare it under 'params' as mentioned here [...

How do I pass params through an AJAX form to create.js while retaining the params?

ruby-on-rails,ajax,params
I have some comments that have a vote score, and I filter them by recent and popular using a toggle. When I click popular, it passes sort: popular as params, and resorts the comment list based on that. Then when a user posts another comment using AJAX, i'm trying to...

param is missing or the value is empty: contacts

ruby-on-rails,ruby,actionmailer,params,form-for
I'm trying to submit my contact form which is supposed to send an email. Every time I click the submit button I get this error: "param is missing or the value is empty: contacts". My routes.rb: Rails.application.routes.draw do resources :contacts root to: 'static#actor_list' get 'static/actor_list' get 'actor' => 'static#actor' get...

Route Generation error for :create action in Minitest

ruby-on-rails,routes,params,minitest
I am currently writing functional tests for all of my controllers. For every single one, I can't get the create action to work. I keep getting the following error when I run rake test: ActionController::UrlGenerationError: No route matches {:action=>"create", :comment=>{:content=>"I'm a comment.", :product_id=>"685617403"}, :controller=>comments} Here is the action I am...

Passing params to an angular service from a controller?

javascript,angularjs,service,controller,params
I'm an angular newby. I'm hoping to pass params to a service that fetches data form a server depending on those params. for example, if I want to pass a book name string and then use it in the service to concatenate with the request url. The documentation does not...

Can't write class with params as property

c#,class,properties,params
It seems I can't write a class with params as property. Is there any way to set params property for class? For a method, I can do this: public static void Method(double x,params double[] k) { } I would like a class that takes unknown number of arguments. class: public...

Rails 4 Integration Testing Arrays not present in json object inside controllers

ruby-on-rails,ruby,json,integration-testing,params
I'm trying to create an integration testing for the creating of a record called books. I'm having problems creating the hash in the tests. This is my code: test/integration/creating_book_test.rb require 'test_helper' class CreatingBookTest < ActionDispatch::IntegrationTest def setup @michael_lewis = Author.create!(name: 'Michael Lewis') @business = Genre.create!(name: 'Business') @sports = Genre.create!(name: 'Sports')...