or you can use this in your view:

<%= collection_select(:video, :category_id, Category.all, :id, :name)
%>

Category.all can be called in your controller and passed to the form
tag as instance variable... something like

@categories = Category.all

then

<%= collection_select(:video, :category_id, @categories, :id, :name)
%>

On Feb 16, 11:50 am, Bala <[email protected]> wrote:
> on Controller
> ----------------------------
>
> def index
>   �...@categories = Category.find(:all)
> end
>
> on View
> ----------------------------------------
> <%= select("post", "category_id", @categories.collect {|p| [ p.name, p.id ]
>
> }, {:include_blank => 'None'})%>
> On Tue, Feb 16, 2010 at 5:08 PM, Veena Jose <[email protected]> wrote:
> > Hello Friends,
> > I am a newbie in ROR.
> > Can you plz tell me how to populate the combobox with data from db?If
> > you could give both the view and controller part it would be helpful.I
> > am using a Mysql database
> > --
> > Posted viahttp://www.ruby-forum.com/.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Ruby on Rails: Talk" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> > [email protected]<rubyonrails-talk%[email protected]>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/rubyonrails-talk?hl=en.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to