Thanks Radhames. Ok I got it up to there. I am assuming since we are
creating controllers for city_suggestions and business_suggestions, we
will also need to create view for them respectively? i.e. /app/views/
city_suggestions and /app/views/business_suggestions right?

I appreciate your patience and thorough explanation regarding STI.
Once I grasp this concept properly, I can apply the same knowledge on
other cases :-)

On Sep 9, 10:26 pm, radhames brito <rbri...@gmail.com> wrote:
> sorry i forgot you use scaffold , here is the thing ill make a guide for
> this , from the migration step by step to the view
>
> create a table like this
>
> create_table :sugestions do |t|
>  t.string first_name
>  t.string last_name
>  t.string email
>  t.string business_name
>  t.string business_address
>  t.string city_name
>  t.string type
>  end
>
> no more tables are needed
>
> create a model
>
> Sugestion , (singular) as normal it should inherit from active record base
> like this
>
> class Sugestion < ActiveRecord::Base
>
> attr_accessible : first_name,last_name, email, business_name,
> business_address, city_name
>
> then create the tu other model that inherit from Sugestion, note that is
> they is a capital letter in the model name rails will put an underscore like
> this city_sugestions_controller
>
> class CitySugestion < ActiveRecord::Base
>
> attr_accessible : first_name,last_name, email, city_name
>
> and another
>
> class bussinessSugestion < ActiveRecord::Base
>
> attr_accessible : first_name,last_name, email,business_name,
> business_address
>
> note i think type should  not be available with mass assignment.
>
> then create the controllers for the 2 sugestions classes
>
> city_sugestions_controller
>
> and
>
> bussiness_sugestions_controller
>
> from here one this controller will never notice you have only one table they
> will behave as if you had 2 different tables in the db
>
> in you views just refer to @bussinesssugestions and it will be scoped thanks
> to the type field that active record will automaticly use then you save an
> object of either class. Dont try to access the type field using
> @citysuggestion.type or @suggestion.type as type is a ruby method and will
> be called instead of
> the table field, use @sugestion[:type] , the other fields can be called as
> normal.
>
> If you want to handle the sugestion class directly you can create a
> sugestions_controller, it its corresponding viwes for it and have a named
> scope that filter each type.
>
> Dont be afraid to keep asking if you are still confuse and keep in mind that
> in most case, people are not specting that you would use scaffolds every
> time since scaffold are more like a learning tool that an actual way of
> doing things.
>
> if you want to use scaffold anyway you can create the scaffold and skip
> creating the migrations with
>
> script/generate scaffold --skip-migrations
>
> On Thu, Sep 9, 2010 at 9:52 AM, Christian Fazzini <
>
> christian.fazz...@gmail.com> wrote:
> > Yes I know, I am just trying to understand how to implement this
> > properly. It's easy enough to rollback the migration and remove the
> > respective migration files. However, I need to know whether I need
> > controllers, models and views for citysuggestion and
> > businesssuggestion
>
> > On Sep 9, 9:46 pm, Marnen Laibow-Koser <li...@ruby-forum.com> wrote:
> > > Christian Fazzini wrote:
> > > > I thought you said I needed to scaffold the citysuggestion and
> > > > businesssuggestion? Scaffold generates controllers, views, and models
> > > > (if they already dont exist)?
>
> > > > If I do rake db:migrate, it generates the tables in the db. Should I
> > > > remove the migration files that the scaffold generator generates
> > > > before doing rake db:migrate?
>
> > > Stop relying so much on the scaffold generator.  You've probably gone
> > > beyond the point where it's useful.
>
> > > Best,
> > > --
> > > Marnen Laibow-Koserhttp://www.marnen.org
> > > mar...@marnen.org
> > > --
> > > 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 rubyonrails-t...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > rubyonrails-talk+unsubscr...@googlegroups.com<rubyonrails-talk%2bunsubscr...@googlegroups.com>
> > .
> > 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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to