Posts

Showing posts with the label rails select box

select box Send Id, display name..

Hi, used this to send the ID in params & display name in the select box. select_tag "user", options_from_collection_for_select(User.all, :id, :name) For adding option & showing selected params, select_tag "user_id", "<option>select one</option>" + options_from_collection_for_select(User.all, :id, :name, params[:user_id].to_i) -- sri.

Rails - select class not applied

Hi, previously my code was like this, I tried much using, html_options, options, but class is not applied for select. <%= f.select 'difficulty', options_for_select({ "Easy" => "1", "Medium" => "3", "Hard" => "5"}, get_difficulty(@tour).to_s), :class =>'input_text' %> Right way to do: <%= select :tour, :difficulty, { "Easy" => "1", "Medium" => "3", "Hard" => "5"}, {:selected=>get_difficulty(@tour).to_s}, :class=>"input_text" %> Now class is applied!!! Any other better way pls tel me,,.</span>

Select Helper Methods in Rails

Image
Hi, Whenever i use a select Box in Rails, i have used this link.. This s really useful.. http://shiningthrough.co.uk/Select-helper-methods-in-Ruby-on-Rails Thanks, Srikanth Tutorials: Ruby on Rails 3 Tutorial: Learn Rails by Example | Ajax on Rails | Rails 3 Way, The (2nd Edition) (Addison-Wesley Professional Ruby Series)