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?

On Sep 9, 9:20 pm, radhames brito <rbri...@gmail.com> wrote:
> errr, there was suppose to be only on table, and 3 model, one that really is
> the table and the other that inherit from the base one, thats why it does
> not save to the citysuggestions table, its not suppose to exist, you are
> user the same table for both models because their only difference are 2
> fields. Treat city_sugestions as if it has its own table , but dont create a
> table for it.
>
> I forgot to maention that the table should have a field called type so that
> when active record saves , it will save what type of sugestions you are
> saving to read a sugestion user sugestion[:type]= city_sugestion or just do
> City_sugestion.find(:all)
>
> i have to go to work no ill be available in 40 mintutes if you need more
> details
>
> On Thu, Sep 9, 2010 at 8:57 AM, Christian Fazzini <
>
> christian.fazz...@gmail.com> wrote:
> > Hi Redhames,
>
> > Ok my form for city_suggestions looks like:
>
> > <% form_for @city_suggestion do |f| %>
> >  <%= f.error_messages %>
>
> >  <p>
> >    <%= f.label :first_name %><br />
> >    <%= f.text_field :first_name %>
> >  </p>
> >  <p>
> >    <%= f.label :last_name %><br />
> >    <%= f.text_area :last_name %>
> >  </p>
> >  <p>
> >    <%= f.label :email %><br />
> >    <%= f.text_field :email %>
> >  </p>
> >  <p>
> >    <%= f.label :city_name %><br />
> >    <%= f.text_field :city_name %>
> >  </p>
>
> >  <p>
> >    <%= f.submit 'Save' %>
> >  </p>
> > <% end %>
>
> > When I submit this, it saves this into the Suggestions table. However,
> > the entry is not saved in the CitySuggestions table. Should I have a
> > line in my CitySuggestions that explicitly saves the entry to this
> > table as well? Or is RoR supposed to do this automatically?
>
> > On Sep 8, 5:46 am, radhames brito <rbri...@gmail.com> wrote:
> > > well, from now on you can forget about the base model if you want to and
> > use
> > > everything as if they are 3 table and 3 models, do as you would normally
> > > would with a simple model just dont use the base BaseSugesstions unless
> > is
> > > an admin and want to do something special. create scaffolds for
> > > citySugesstions and BussinesSuggestion (by the way there is a typo en my
> > > example the second class is supposed to be BussinesSuggestion not
> > > BaseSuggestion) with free access to create and their own views and forms.
> > > For adminsitration purposes and for your  benefit create a basesugetion
> > > controller for staticstics, un the base model you can use all kinds of
> > > scopes to check and compare.
>
> > > On Tue, Sep 7, 2010 at 3:30 PM, Christian Fazzini <
>
> > > christian.fazz...@gmail.com> wrote:
> > > > Radhames, how do I go about creating the controllers for
> > > > CitySuggestion and BusinessSuggestion? Can I use the scaffold
> > > > generator for these two?
>
> > > > Or should I use the Suggestions controller to handle both? For
> > > > example, where is the view/form to add new CitySuggestion? Should this
> > > > be in the Suggestions controller?
>
> > > > I'm a bit confused here...
>
> > > > On Sep 8, 12:02 am, radhames brito <rbri...@gmail.com> wrote:
> > > > > no you need single table inheritance
>
> > > > > is way better in your case , read a bit about STI, it lets you create
> > one
> > > > > table and one model and then inherit from that model
>
> > > > > list this
>
> > > > > class BaseSugesstions < ActiveRecord :: base
>
> > > > > attr_accessible first_name, last_name, email, city_name,
> > business_name
>
> > > > > end
>
> > > > > then
>
> > > > > class citySugesstions < BaseSugesstions
>
> > > > > attr_accessible first_name, last_name, email, city_name
>
> > > > > end
>
> > > > > class BaseSugesstions < BaseSugesstions
>
> > > > > attr_accessible first_name, last_name, email, business_name
>
> > > > > end
>
> > > > > one table should on the database should have all the field defined in
> > > > > BaseSugesstions
>
> > > > > On Tue, Sep 7, 2010 at 11:25 AM, Christian Fazzini <
>
> > > > > christian.fazz...@gmail.com> wrote:
> > > > > > Hi Ar,
>
> > > > > > End-users can either be registered or non-registered users. Any
> > type
> > > > > > of user can suggest a business and a city.
>
> > > > > > When they suggest a city, they have to put in their first_name,
> > > > > > last_name, email and city name.
>
> > > > > > When they suggest a business. They have to put in their first_name,
> > > > > > last_name, email, business name and business address.
>
> > > > > > Initially, I had it working with two separate models:
> > city_suggestion
> > > > > > and business_suggestion. However, since both tables have fields
> > that
> > > > > > can be reused (i.e. first_name, last_name, email), I was thinking
> > of
> > > > > > using a polymorphic association.
>
> > > > > > I am not sure if this is the right approach or whether I should
> > have
> > > > > > just stuck with my original solution (i.e. two separate tables:
> > > > > > city_suggestion and business_suggestion)
>
> > > > > > On Sep 7, 11:02 pm, Ar Chron <li...@ruby-forum.com> wrote:
> > > > > > > Hmm... seems my interpretation of what you are attempting to do
> > > > doesn't
> > > > > > > match very well with your unstated goals...  You were asking
> > whether
> > > > the
> > > > > > > suggestion model should be polymorphic...
>
> > > > > > > Sooo, what exactly is a suggestion in the context of your
> > application
> > > > > > > (what are your users doing)?
> > > > > > > --
> > > > > > > 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-talk@googlegroups.com
> > > > .
> > > > > > To unsubscribe from this group, send email to
> > > > > > rubyonrails-talk+unsubscr...@googlegroups.com<rubyonrails-talk%2bunsubscr...@googlegroups.com>
> > <rubyonrails-talk%2bunsubscr...@googlegroups.com<rubyonrails-talk%252bunsubscr...@googlegroups.com>
>
> > > > <rubyonrails-talk%2bunsubscr...@googlegroups.com<rubyonrails-talk%252bunsubscr...@googlegroups.com>
> > <rubyonrails-talk%252bunsubscr...@googlegroups.com<rubyonrails-talk%25252bunsubscr...@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-talk@googlegroups.com
> > .
> > > > To unsubscribe from this group, send email to
> > > > rubyonrails-talk+unsubscr...@googlegroups.com<rubyonrails-talk%2bunsubscr...@googlegroups.com>
> > <rubyonrails-talk%2bunsubscr...@googlegroups.com<rubyonrails-talk%252bunsubscr...@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<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