Hey Ruby on Rails Community i''m trying to Add Categories to my Rails app, but don''t quite know how to do this. I have many Pins(Images) and want the user to be able to assign a category on those Pins. ASSIGN not create, edit, or delete a Category, just selecting one for their Pin. Meaning that, When a user uploads a pin, he can choose from a dropdown list a Category. Then, another user can choose from the Menu a Category, and ONLY the Pins in this Category will be listed. How do i do this? Where to start ? Thank you -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/f9fe7e67ce400e68c7f9953c1e034b15%40ruby-forum.com. For more options, visit https://groups.google.com/groups/opt_out.
Giannakis P. wrote in post #1116088:> Hey Ruby on Rails Community > > i''m trying to Add Categories to my Rails app, but don''t quite know how > to do this. > > I have many Pins(Images) and want the user to be able to assign a > category on those Pins. ASSIGN not create, edit, or delete a Category, > just selecting one for their Pin. Meaning that, When a user uploads a > pin, he can choose from a dropdown list a Category. > > Then, another user can choose from the Menu a Category, and ONLY the > Pins in this Category will be listed. > > How do i do this? Where to start ?Sounds to me like a tagging system such as https://github.com/mbleigh/acts-as-taggable-on would work well for your needs. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/e70b5e69688c2b90232f828a035aa664%40ruby-forum.com. For more options, visit https://groups.google.com/groups/opt_out.
Hello Robert :) No no, i need a clear category table. Here''s what i done I generated a migration class AddCategoriesToPins < ActiveRecord::Migration def change add_column :pins, :category, :string end end in my Pin Uploading form i added <%= f.select :category, [ ''Box'', ''Cover'', ''Poster'' ], :prompt => ''Select One'' %> Now, the Selecting a Category when uploading Works, and the category shows up properly in the Database. But i want the user to click on that category in the Show Page and see all the pin''s that are in that category. P.S.: Is this method even a good one ? I dont want the user''s to be able to create, edit, or delete a Category. Just selecting it. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/7f3f769d661bad459f8186da6372740c%40ruby-forum.com. For more options, visit https://groups.google.com/groups/opt_out.
On Jul 20, 2013, at 12:56 AM, Giannakis P. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hey Ruby on Rails Community > > i''m trying to Add Categories to my Rails app, but don''t quite know how > to do this. > > I have many Pins(Images) and want the user to be able to assign a > category on those Pins. ASSIGN not create, edit, or delete a Category, > just selecting one for their Pin. Meaning that, When a user uploads a > pin, he can choose from a dropdown list a Category. > > Then, another user can choose from the Menu a Category, and ONLY the > Pins in this Category will be listed. > > How do i do this? Where to start ? > > Thank youIt sounds as though you are going to limit them to one category per pin. Simply using that, a given pin will belong to a category, and a category will have many pins. This should tell you the relationship to use. Read the rails guide on relationships for how to set this up. Since you are not allowing the user to define categories, you will need, as an admin or as part of your app configuration, to fill in the categories you want your users to be able to select from. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/8937B012-B38B-4F00-A3BF-E1C5359C15AB%40gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
On Jul 20, 2013, at 10:21 PM, Giannakis P. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hello Robert :) > > No no, i need a clear category table. Here''s what i done > > I generated a migration > > class AddCategoriesToPins < ActiveRecord::Migration > def change > add_column :pins, :category, :string > end > end > > in my Pin Uploading form i added > > <%= f.select :category, [ ''Box'', ''Cover'', ''Poster'' ], :prompt => ''Select > One'' %> > > Now, the Selecting a Category when uploading Works, and the category > shows up properly in the Database. > > But i want the user to click on that category in the Show Page and see > all the pin''s that are in that category. > > P.S.: Is this method even a good one ? I dont want the user''s to be able > to create, edit, or delete a Category. Just selecting it.This can certainly work, though seems less flexible in the long run as to update categories you have to go into the code base and make the change there, rather than have a configurable set in a table. But even with this, it''s quite possible, but again, you''re necessarily hard coding the selection instead of drawing it from a table. In you category navigation, you offer the user the ability to select on of Box, Cover or Poster, and then use gather them in the appropriate controller with pins = Pin.where(:category => params[:category]) for example (depending on how you actually get the user''s desired category). -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/E94B359C-5F04-4D40-99B9-FD44CB84C6D0%40gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
It seems like the best way to do this is to generate a Categories scaffold and allowing only admins to create, update or Delete the Categories. This is the Easy Part, i get this. But now, how do i get the selection dropdown in to my form, allowing users to choose a category? :( -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/c60c8d5ff41d53a00f7f5f4fdda387f0%40ruby-forum.com. For more options, visit https://groups.google.com/groups/opt_out.