I understand that controller''s are basically the link between views and models. However, I''m a little confused as to how a controller should be structured beyond CRUD functionality. Here''s a use case: During the creation of a new object the user will be asked to input a parameter. The parameter will be used to perform a search to help ensure the object doesn''t already exist in the system before continuing. I''m not sure where that search procedure should be located. I could put it in middleware controller but I''m not sure if that''s the most appropriate place. Do any of you more seasoned Rails developers have any insight? -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Wed, Sep 8, 2010 at 9:30 PM, Anthony Smith <anthony-pO6LffClugqiCYHjmAE91gC/G2K4zDHf@public.gmane.org>wrote:> I understand that controller''s are basically the link between views and > models. However, I''m a little confused as to how a controller should be > structured beyond CRUD functionality. > > Here''s a use case: > > During the creation of a new object the user will be asked to input a > parameter. The parameter will be used to perform a search to help ensure the > object doesn''t already exist in the system before continuing. > > I''m not sure where that search procedure should be located. I could put it > in middleware controller but I''m not sure if that''s the most appropriate > place. > > Do any of you more seasoned Rails developers have any insight? >Does this parameter entry occur along with the object parameters? As in, on the "new" page? It sounds like the search is part of the object creation, i.e. in the create action, to me. If it fails, redirect back to the new page just like a failed save would. Adam Stegman -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Here''s the logic: A user will navigate to the "new" page A user will be presented with an input box The user enters a value A search will be performed using AJAX If a search comes up with nothing a transition will occur providing the user the ability to enter the rest of the information It''s logically separate from actually creating the object. On Sep 8, 2010, at 10:48 PM, Adam wrote:> On Wed, Sep 8, 2010 at 9:30 PM, Anthony Smith <anthony-pO6LffClugqiCYHjmAE91gC/G2K4zDHf@public.gmane.org> wrote: > I understand that controller''s are basically the link between views and models. However, I''m a little confused as to how a controller should be structured beyond CRUD functionality. > > Here''s a use case: > > During the creation of a new object the user will be asked to input a parameter. The parameter will be used to perform a search to help ensure the object doesn''t already exist in the system before continuing. > > I''m not sure where that search procedure should be located. I could put it in middleware controller but I''m not sure if that''s the most appropriate place. > > Do any of you more seasoned Rails developers have any insight? > > Does this parameter entry occur along with the object parameters? As in, on the "new" page? It sounds like the search is part of the object creation, i.e. in the create action, to me. If it fails, redirect back to the new page just like a failed save would. > > Adam Stegman > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
What you have is a problem of validation, so creation is like this, you have a form in the view , pass the info/paremeters to the controller and the controller will try to save the information, when it passes the object to the model for saving validation will kick in, as validation is a responsibility of the model , so you will have something like this in the model, validates_uniqueness_of :whatever and you can even scope that uniqueness adding :scope => city so the model will check that there is only one whatever per city. the model will scream to the action and the actions will show the error is you have a error_message_for helper in the view. On Wed, Sep 8, 2010 at 10:48 PM, Adam <astegman-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Wed, Sep 8, 2010 at 9:30 PM, Anthony Smith <anthony-pO6LffClugqiCYHjmAE91gC/G2K4zDHf@public.gmane.org>wrote: > >> I understand that controller''s are basically the link between views and >> models. However, I''m a little confused as to how a controller should be >> structured beyond CRUD functionality. >> >> Here''s a use case: >> >> During the creation of a new object the user will be asked to input a >> parameter. The parameter will be used to perform a search to help ensure the >> object doesn''t already exist in the system before continuing. >> >> I''m not sure where that search procedure should be located. I could put it >> in middleware controller but I''m not sure if that''s the most appropriate >> place. >> >> Do any of you more seasoned Rails developers have any insight? >> > > Does this parameter entry occur along with the object parameters? As in, on > the "new" page? It sounds like the search is part of the object creation, > i.e. in the create action, to me. If it fails, redirect back to the new page > just like a failed save would. > > Adam Stegman > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Wed, Sep 8, 2010 at 10:05 PM, Anthony Smith <anthony-pO6LffClugqiCYHjmAE91gC/G2K4zDHf@public.gmane.org>wrote:> Here''s the logic: > > > 1. A user will navigate to the "new" page > 2. A user will be presented with an input box > 3. The user enters a value > 4. A search will be performed using AJAX > 5. If a search comes up with nothing a transition will occur providing > the user the ability to enter the rest of the information > > > It''s logically separate from actually creating the object. >Ah, I see now. That would certainly be a separate action, then. Depending on how your search is structured, it may be something like /things/search?q=<query> or /search?q=<query> Assuming the first, you''d define your action> def search > # perform search > respond_to do |format| > format.js # ajax response, search.js.erb > # OR > format.json { render :json => some_hash } > end > end-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
oh i see, you want to check if a value was used? ok , you will have to add a custom restful action, for the search, then catch the click event , i recomend using jquery and respond with a template that has js.erb extantion to excute the code is quite simple maybe sustitude a partial or redirect. On Wed, Sep 8, 2010 at 11:05 PM, Anthony Smith <anthony-pO6LffClugqiCYHjmAE91gC/G2K4zDHf@public.gmane.org>wrote:> Here''s the logic: > > > 1. A user will navigate to the "new" page > 2. A user will be presented with an input box > 3. The user enters a value > 4. A search will be performed using AJAX > 5. If a search comes up with nothing a transition will occur providing > the user the ability to enter the rest of the information > > > It''s logically separate from actually creating the object. > > On Sep 8, 2010, at 10:48 PM, Adam wrote: > > On Wed, Sep 8, 2010 at 9:30 PM, Anthony Smith <anthony-pO6LffClugqiCYHjmAE91gC/G2K4zDHf@public.gmane.org>wrote: > >> I understand that controller''s are basically the link between views and >> models. However, I''m a little confused as to how a controller should be >> structured beyond CRUD functionality. >> >> Here''s a use case: >> >> During the creation of a new object the user will be asked to input a >> parameter. The parameter will be used to perform a search to help ensure the >> object doesn''t already exist in the system before continuing. >> >> I''m not sure where that search procedure should be located. I could put it >> in middleware controller but I''m not sure if that''s the most appropriate >> place. >> >> Do any of you more seasoned Rails developers have any insight? >> > > Does this parameter entry occur along with the object parameters? As in, on > the "new" page? It sounds like the search is part of the object creation, > i.e. in the create action, to me. If it fails, redirect back to the new page > just like a failed save would. > > Adam Stegman > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
That''s not what I''m quite trying to accomplish. This might help: If a user wants to create a Book in the system I would first ask them to perform a search on the title as part of the process to create a Book so the user can verify uniqueness. Now, there can be multiple different books with the same title. I just want the user to make sure that the exact same book does not exist before creating a duplicate. Hopefully that makes more sense. On Sep 8, 2010, at 11:05 PM, radhames brito wrote:> What you have is a problem of validation, so creation is like this, you have a form in the view , pass the info/paremeters to the controller and the controller will try to save the information, when it passes the object to the model for saving validation will kick in, as validation is a responsibility of the model , so you will have something like this in the model, validates_uniqueness_of :whatever and you can even scope that uniqueness adding :scope => city so the model will check that there is only one whatever per city. the model will scream to the action and the actions will show the error is you have a error_message_for helper in the view. > > > > > > > On Wed, Sep 8, 2010 at 10:48 PM, Adam <astegman-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > On Wed, Sep 8, 2010 at 9:30 PM, Anthony Smith <anthony-pO6LffClugqiCYHjmAE91gC/G2K4zDHf@public.gmane.org> wrote: > I understand that controller''s are basically the link between views and models. However, I''m a little confused as to how a controller should be structured beyond CRUD functionality. > > Here''s a use case: > > During the creation of a new object the user will be asked to input a parameter. The parameter will be used to perform a search to help ensure the object doesn''t already exist in the system before continuing. > > I''m not sure where that search procedure should be located. I could put it in middleware controller but I''m not sure if that''s the most appropriate place. > > Do any of you more seasoned Rails developers have any insight? > > Does this parameter entry occur along with the object parameters? As in, on the "new" page? It sounds like the search is part of the object creation, i.e. in the create action, to me. If it fails, redirect back to the new page just like a failed save would. > > Adam Stegman > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
yea just saw it , put a button with a link to the search action put and id in it then with jquery $(function() { $("#the_button").live("click", function() { $.get(this.href, null, null, "script"); return false; }); }); make a js.erb file with $("#id_with_partial_to_replace").html("#{escape_javascript(render :partial =>"i_failed")}"); or window.location = <%= you_fail_path %> On Wed, Sep 8, 2010 at 11:13 PM, Anthony Smith <anthony-pO6LffClugqiCYHjmAE91gC/G2K4zDHf@public.gmane.org>wrote:> That''s not what I''m quite trying to accomplish. > > This might help: > > If a user wants to create a Book in the system I would first ask them to > perform a search on the title as part of the process to create a Book so the > user can verify uniqueness. Now, there can be multiple different books with > the same title. I just want the user to make sure that the exact same book > does not exist before creating a duplicate. > > Hopefully that makes more sense. > > On Sep 8, 2010, at 11:05 PM, radhames brito wrote: > > What you have is a problem of validation, so creation is like this, you > have a form in the view , pass the info/paremeters to the controller and the > controller will try to save the information, when it passes the object to > the model for saving validation will kick in, as validation is a > responsibility of the model , so you will have something like this in the > model, validates_uniqueness_of :whatever and you can even scope that > uniqueness adding :scope => city so the model will check that there is only > one whatever per city. the model will scream to the action and the actions > will show the error is you have a error_message_for helper in the view. > > > > > > > On Wed, Sep 8, 2010 at 10:48 PM, Adam <astegman-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> On Wed, Sep 8, 2010 at 9:30 PM, Anthony Smith <anthony-pO6LffClugqiCYHjmAE91gC/G2K4zDHf@public.gmane.org>wrote: >> >>> I understand that controller''s are basically the link between views and >>> models. However, I''m a little confused as to how a controller should be >>> structured beyond CRUD functionality. >>> >>> Here''s a use case: >>> >>> During the creation of a new object the user will be asked to input a >>> parameter. The parameter will be used to perform a search to help ensure the >>> object doesn''t already exist in the system before continuing. >>> >>> I''m not sure where that search procedure should be located. I could put >>> it in middleware controller but I''m not sure if that''s the most appropriate >>> place. >>> >>> Do any of you more seasoned Rails developers have any insight? >>> >> >> Does this parameter entry occur along with the object parameters? As in, >> on the "new" page? It sounds like the search is part of the object creation, >> i.e. in the create action, to me. If it fails, redirect back to the new page >> just like a failed save would. >> >> Adam Stegman >> >> -- >> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> >> . >> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Ah, that will help with what I need to do next. However, let''s continue with my Book analogy: Here''s a sample of an object model: Book (ActiveModel) Title (ActiveModel) Now, the user will be performing a search on the Title. However, this is to help facilitate the creation of a Book which contains a Title. Should the search logic be performed in the BookController, TitleController, TitleSearchController or something else? I''m just trying to figure out the best way to structure a controller for this type of situation. Thanks for your help and patience! On Sep 8, 2010, at 11:11 PM, Adam wrote:> On Wed, Sep 8, 2010 at 10:05 PM, Anthony Smith <anthony-pO6LffClugqiCYHjmAE91gC/G2K4zDHf@public.gmane.org> wrote: > Here''s the logic: > > A user will navigate to the "new" page > A user will be presented with an input box > The user enters a value > A search will be performed using AJAX > If a search comes up with nothing a transition will occur providing the user the ability to enter the rest of the information > > It''s logically separate from actually creating the object. > > Ah, I see now. That would certainly be a separate action, then. Depending on how your search is structured, it may be something like > > /things/search?q=<query> > or > /search?q=<query> > > Assuming the first, you''d define your action > > def search > > # perform search > > respond_to do |format| > > format.js # ajax response, search.js.erb > > # OR > > format.json { render :json => some_hash } > > end > > end > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
of coure in your search action you should to respond_to do |format| if Book.find(params[:search]) format.js end end On Wed, Sep 8, 2010 at 11:21 PM, radhames brito <rbritom-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> yea just saw it , > > > put a button with a link to the search action put and id in it then with > jquery > > $(function() { > $("#the_button").live("click", function() { > $.get(this.href, null, null, "script"); > return false; > }); > }); > > > make a js.erb file with > > $("#id_with_partial_to_replace").html("#{escape_javascript(render :partial > =>"i_failed")}"); > > or > > window.location = <%= you_fail_path %> > > > On Wed, Sep 8, 2010 at 11:13 PM, Anthony Smith <anthony-pO6LffClugqiCYHjmAE91gC/G2K4zDHf@public.gmane.org>wrote: > >> That''s not what I''m quite trying to accomplish. >> >> This might help: >> >> If a user wants to create a Book in the system I would first ask them to >> perform a search on the title as part of the process to create a Book so the >> user can verify uniqueness. Now, there can be multiple different books with >> the same title. I just want the user to make sure that the exact same book >> does not exist before creating a duplicate. >> >> Hopefully that makes more sense. >> >> On Sep 8, 2010, at 11:05 PM, radhames brito wrote: >> >> What you have is a problem of validation, so creation is like this, you >> have a form in the view , pass the info/paremeters to the controller and the >> controller will try to save the information, when it passes the object to >> the model for saving validation will kick in, as validation is a >> responsibility of the model , so you will have something like this in the >> model, validates_uniqueness_of :whatever and you can even scope that >> uniqueness adding :scope => city so the model will check that there is only >> one whatever per city. the model will scream to the action and the actions >> will show the error is you have a error_message_for helper in the view. >> >> >> >> >> >> >> On Wed, Sep 8, 2010 at 10:48 PM, Adam <astegman-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >>> On Wed, Sep 8, 2010 at 9:30 PM, Anthony Smith <anthony-pO6LffClugqiCYHjmAE91gC/G2K4zDHf@public.gmane.org >>> > wrote: >>> >>>> I understand that controller''s are basically the link between views and >>>> models. However, I''m a little confused as to how a controller should be >>>> structured beyond CRUD functionality. >>>> >>>> Here''s a use case: >>>> >>>> During the creation of a new object the user will be asked to input a >>>> parameter. The parameter will be used to perform a search to help ensure the >>>> object doesn''t already exist in the system before continuing. >>>> >>>> I''m not sure where that search procedure should be located. I could put >>>> it in middleware controller but I''m not sure if that''s the most appropriate >>>> place. >>>> >>>> Do any of you more seasoned Rails developers have any insight? >>>> >>> >>> Does this parameter entry occur along with the object parameters? As in, >>> on the "new" page? It sounds like the search is part of the object creation, >>> i.e. in the create action, to me. If it fails, redirect back to the new page >>> just like a failed save would. >>> >>> Adam Stegman >>> >>> -- >>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> To unsubscribe from this group, send email to >>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> >>> . >>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> >> . >> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
why there is a title model ? there is no need to , the title is a field of the books table, and you only need to add a new action to the BooksController (plural for controllers), to make the new action restful add this next to the map.resources :book , :member => {:make_up_a_name => :post} then do rake routes and checkout the new restful route you have. It even has a helper method which you can use as the href for the button that triggers the ajax, the method is make_up_a_name_book_path in this example. On Wed, Sep 8, 2010 at 11:26 PM, Anthony Smith <anthony-pO6LffClugqiCYHjmAE91gC/G2K4zDHf@public.gmane.org>wrote:> Ah, that will help with what I need to do next. > > However, let''s continue with my Book analogy: > > Here''s a sample of an object model: > > Book (ActiveModel) > Title (ActiveModel) > > Now, the user will be performing a search on the Title. However, this is to > help facilitate the creation of a Book which contains a Title. Should the > search logic be performed in the BookController, TitleController, > TitleSearchController or something else? > > I''m just trying to figure out the best way to structure a controller for > this type of situation. > > Thanks for your help and patience! > > On Sep 8, 2010, at 11:11 PM, Adam wrote: > > On Wed, Sep 8, 2010 at 10:05 PM, Anthony Smith <anthony-pO6LffClugqiCYHjmAE91gC/G2K4zDHf@public.gmane.org>wrote: > >> Here''s the logic: >> >> >> 1. A user will navigate to the "new" page >> 2. A user will be presented with an input box >> 3. The user enters a value >> 4. A search will be performed using AJAX >> 5. If a search comes up with nothing a transition will occur providing >> the user the ability to enter the rest of the information >> >> >> It''s logically separate from actually creating the object. >> > > Ah, I see now. That would certainly be a separate action, then. Depending > on how your search is structured, it may be something like > > /things/search?q=<query> > or > /search?q=<query> > > Assuming the first, you''d define your action > > def search > > # perform search > > respond_to do |format| > > format.js # ajax response, search.js.erb > > # OR > > format.json { render :json => some_hash } > > end > > end > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
with plural for controllers i meant that you wrote BookController and is BooksController model names go plural in the controllers On Wed, Sep 8, 2010 at 11:36 PM, radhames brito <rbritom-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> why there is a title model ? there is no need to , the title is a field of > the books table, and you only need to add a new action to the > BooksController (plural for controllers), to make the new action restful add > this next to the map.resources :book , :member => {:make_up_a_name => :post} > > then do rake routes and checkout the new restful route you have. It even > has a helper method which you can use as the href for the button that > triggers the ajax, the method is make_up_a_name_book_path in this example. > > > On Wed, Sep 8, 2010 at 11:26 PM, Anthony Smith <anthony-pO6LffClugqiCYHjmAE91gC/G2K4zDHf@public.gmane.org>wrote: > >> Ah, that will help with what I need to do next. >> >> However, let''s continue with my Book analogy: >> >> Here''s a sample of an object model: >> >> Book (ActiveModel) >> Title (ActiveModel) >> >> Now, the user will be performing a search on the Title. However, this is >> to help facilitate the creation of a Book which contains a Title. Should the >> search logic be performed in the BookController, TitleController, >> TitleSearchController or something else? >> >> I''m just trying to figure out the best way to structure a controller for >> this type of situation. >> >> Thanks for your help and patience! >> >> On Sep 8, 2010, at 11:11 PM, Adam wrote: >> >> On Wed, Sep 8, 2010 at 10:05 PM, Anthony Smith <anthony-pO6LffClugqiCYHjmAE91gC/G2K4zDHf@public.gmane.org >> > wrote: >> >>> Here''s the logic: >>> >>> >>> 1. A user will navigate to the "new" page >>> 2. A user will be presented with an input box >>> 3. The user enters a value >>> 4. A search will be performed using AJAX >>> 5. If a search comes up with nothing a transition will occur >>> providing the user the ability to enter the rest of the information >>> >>> >>> It''s logically separate from actually creating the object. >>> >> >> Ah, I see now. That would certainly be a separate action, then. Depending >> on how your search is structured, it may be something like >> >> /things/search?q=<query> >> or >> /search?q=<query> >> >> Assuming the first, you''d define your action >> > def search >> > # perform search >> > respond_to do |format| >> > format.js # ajax response, search.js.erb >> > # OR >> > format.json { render :json => some_hash } >> > end >> > end >> >> -- >> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> >> . >> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Wed, Sep 8, 2010 at 10:36 PM, radhames brito <rbritom-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> why there is a title model ? there is no need to , the title is a field of > the books table, and you only need to add a new action to the > BooksController (plural for controllers), to make the new action restful add > this next to the map.resources :book , :member => {:make_up_a_name => :post} > > then do rake routes and checkout the new restful route you have. It even > has a helper method which you can use as the href for the button that > triggers the ajax, the method is make_up_a_name_book_path in this example. > >Why would it be a member action? If he''s searching for a book, he doesn''t know yet what book he wants - it would be a collection action. I would also expect it to be a GET, not a POST, since he''s retrieving search results, not creating anything. GET /books/search?title=<query> Adam Stegman -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
true is a :get not a :post( typo maybe i was thinking :get but wrote :post), but it is a member action because only one name will be returned, note that he is checking if the is more than one book with that name if that is the case he will not allow the creation so there should never be more than one and the action will only return one record On Wed, Sep 8, 2010 at 11:45 PM, Adam <astegman-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Wed, Sep 8, 2010 at 10:36 PM, radhames brito <rbritom-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> why there is a title model ? there is no need to , the title is a field of >> the books table, and you only need to add a new action to the >> BooksController (plural for controllers), to make the new action restful add >> this next to the map.resources :book , :member => {:make_up_a_name => :post} >> >> then do rake routes and checkout the new restful route you have. It even >> has a helper method which you can use as the href for the button that >> triggers the ajax, the method is make_up_a_name_book_path in this example. >> >> > Why would it be a member action? If he''s searching for a book, he doesn''t > know yet what book he wants - it would be a collection action. I would also > expect it to be a GET, not a POST, since he''s retrieving search results, not > creating anything. > > GET /books/search?title=<query> > > Adam Stegman > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
:get member action create singular methods and return one object :get collection actions create plural methods and return and array of objects On Wed, Sep 8, 2010 at 11:49 PM, radhames brito <rbritom-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> true is a :get not a :post( typo maybe i was thinking :get but wrote > :post), but it is a member action because only one name will be returned, > note that he is checking if the is more than one book with that name if that > is the case he will not allow the creation so there should never be more > than one and the action will only return one record > > > > > > On Wed, Sep 8, 2010 at 11:45 PM, Adam <astegman-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> On Wed, Sep 8, 2010 at 10:36 PM, radhames brito <rbritom-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: >> >>> why there is a title model ? there is no need to , the title is a field >>> of the books table, and you only need to add a new action to the >>> BooksController (plural for controllers), to make the new action restful add >>> this next to the map.resources :book , :member => {:make_up_a_name => :post} >>> >>> then do rake routes and checkout the new restful route you have. It even >>> has a helper method which you can use as the href for the button that >>> triggers the ajax, the method is make_up_a_name_book_path in this example. >>> >>> >> Why would it be a member action? If he''s searching for a book, he doesn''t >> know yet what book he wants - it would be a collection action. I would also >> expect it to be a GET, not a POST, since he''s retrieving search results, not >> creating anything. >> >> GET /books/search?title=<query> >> >> Adam Stegman >> >> -- >> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> >> . >> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Let''s suppose a Book can have multiple Title''s based on language. So there can be an english title and a Spanish title for a single book. So the object model would look more like this: Book (ActiveModel) Titles (array of ActiveModels) Solr will be used for search. Logically, where should the search action be placed? A model/view doesn''t always have a 1-to-1 relationship. So putting a search action in the BooksController doesn''t seem logical to me. I guess I don''t completely understand the controller''s relationship between the model/controller. Does a controller lean more towards a view or model? If it has more of a bias towards a view then it seems like a TitlesSearchController makes more sense. If it''s more model based, then a TitlesController with a search action would make more sense. On Sep 8, 2010, at 11:36 PM, radhames brito wrote:> why there is a title model ? there is no need to , the title is a field of the books table, and you only need to add a new action to the BooksController (plural for controllers), to make the new action restful add this next to the map.resources :book , :member => {:make_up_a_name => :post} > > then do rake routes and checkout the new restful route you have. It even has a helper method which you can use as the href for the button that triggers the ajax, the method is make_up_a_name_book_path in this example. > > On Wed, Sep 8, 2010 at 11:26 PM, Anthony Smith <anthony-pO6LffClugqiCYHjmAE91gC/G2K4zDHf@public.gmane.org> wrote: > Ah, that will help with what I need to do next. > > However, let''s continue with my Book analogy: > > Here''s a sample of an object model: > > Book (ActiveModel) > Title (ActiveModel) > > Now, the user will be performing a search on the Title. However, this is to help facilitate the creation of a Book which contains a Title. Should the search logic be performed in the BookController, TitleController, TitleSearchController or something else? > > I''m just trying to figure out the best way to structure a controller for this type of situation. > > Thanks for your help and patience! > > On Sep 8, 2010, at 11:11 PM, Adam wrote: > >> On Wed, Sep 8, 2010 at 10:05 PM, Anthony Smith <anthony-pO6LffClugqiCYHjmAE91g@public.gmane.orgm> wrote: >> Here''s the logic: >> >> A user will navigate to the "new" page >> A user will be presented with an input box >> The user enters a value >> A search will be performed using AJAX >> If a search comes up with nothing a transition will occur providing the user the ability to enter the rest of the information >> >> It''s logically separate from actually creating the object. >> >> Ah, I see now. That would certainly be a separate action, then. Depending on how your search is structured, it may be something like >> >> /things/search?q=<query> >> or >> /search?q=<query> >> >> Assuming the first, you''d define your action >> > def search >> > # perform search >> > respond_to do |format| >> > format.js # ajax response, search.js.erb >> > # OR >> > format.json { render :json => some_hash } >> > end >> > end >> >> -- >> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Wed, Sep 8, 2010 at 10:55 PM, Anthony Smith <anthony-pO6LffClugqiCYHjmAE91gC/G2K4zDHf@public.gmane.org>wrote:> Logically, where should the search action be placed? A model/view doesn''t > always have a 1-to-1 relationship. So putting a search action in the > BooksController doesn''t seem logical to me. I guess I don''t completely > understand the controller''s relationship between the model/controller. Does > a controller lean more towards a view or model? If it has more of a bias > towards a view then it seems like a TitlesSearchController makes more sense. > If it''s more model based, then a TitlesController with a search action would > make more sense. >A RESTful controller is based around a resource. In this case, you''re searching a resource to see if it has a record matching your query, so it makes sense to me to put it in /titles/search. Adam Stegman -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Wed, Sep 8, 2010 at 10:49 PM, radhames brito <rbritom-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> true is a :get not a :post( typo maybe i was thinking :get but wrote > :post), but it is a member action because only one name will be returned, > note that he is checking if the is more than one book with that name if that > is the case he will not allow the creation so there should never be more > than one and the action will only return one recordA member action acts on a single member. How can you act on an unknown member?> resources :titles do > member do > get :search > end > endwould create a URL like: /titles/:id/search What would you suggest putting as the ID? Instead, this is acting upon the /titles collection of resources, searching for something that exists within it. As such, the URL would be: /titles/search Adam Stegman -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Okay, I think I''m getting caught up on the resources. I''ll look more into that for the time being. Thanks a lot for you help! On Sep 8, 2010, at 11:59 PM, Adam wrote:> On Wed, Sep 8, 2010 at 10:55 PM, Anthony Smith <anthony-pO6LffClugqiCYHjmAE91gC/G2K4zDHf@public.gmane.org> wrote: > Logically, where should the search action be placed? A model/view doesn''t always have a 1-to-1 relationship. So putting a search action in the BooksController doesn''t seem logical to me. I guess I don''t completely understand the controller''s relationship between the model/controller. Does a controller lean more towards a view or model? If it has more of a bias towards a view then it seems like a TitlesSearchController makes more sense. If it''s more model based, then a TitlesController with a search action would make more sense. > > A RESTful controller is based around a resource. In this case, you''re searching a resource to see if it has a record matching your query, so it makes sense to me to put it in /titles/search. > > Adam Stegman > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
yes is true, i missed that , i think i didnt think ahead, well where i live is pass midnight so that may be it , i think im going to sleep On Thu, Sep 9, 2010 at 12:01 AM, Adam <astegman-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Wed, Sep 8, 2010 at 10:49 PM, radhames brito <rbritom-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> true is a :get not a :post( typo maybe i was thinking :get but wrote >> :post), but it is a member action because only one name will be returned, >> note that he is checking if the is more than one book with that name if that >> is the case he will not allow the creation so there should never be more >> than one and the action will only return one record > > > A member action acts on a single member. How can you act on an unknown > member? > > > resources :titles do > > member do > > get :search > > end > > end > would create a URL like: > /titles/:id/search > What would you suggest putting as the ID? > > Instead, this is acting upon the /titles collection of resources, searching > for something that exists within it. As such, the URL would be: > /titles/search > > Adam Stegman > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
adam is right i mess up listen to him On Thu, Sep 9, 2010 at 12:09 AM, Anthony Smith <anthony-pO6LffClugqiCYHjmAE91gC/G2K4zDHf@public.gmane.org>wrote:> Okay, I think I''m getting caught up on the resources. I''ll look more into > that for the time being. > > Thanks a lot for you help! > > On Sep 8, 2010, at 11:59 PM, Adam wrote: > > On Wed, Sep 8, 2010 at 10:55 PM, Anthony Smith <anthony-pO6LffClugqiCYHjmAE91gC/G2K4zDHf@public.gmane.org>wrote: > >> Logically, where should the search action be placed? A model/view doesn''t >> always have a 1-to-1 relationship. So putting a search action in the >> BooksController doesn''t seem logical to me. I guess I don''t completely >> understand the controller''s relationship between the model/controller. Does >> a controller lean more towards a view or model? If it has more of a bias >> towards a view then it seems like a TitlesSearchController makes more sense. >> If it''s more model based, then a TitlesController with a search action would >> make more sense. >> > > A RESTful controller is based around a resource. In this case, you''re > searching a resource to see if it has a record matching your query, so it > makes sense to me to put it in /titles/search. > > Adam Stegman > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I''m with ya! Time to hit the sack. Thanks so much for your help! On Sep 9, 2010, at 12:10 AM, radhames brito wrote:> yes is true, i missed that , i think i didnt think ahead, well where i live is pass midnight so that may be it , i think im going to sleep > > On Thu, Sep 9, 2010 at 12:01 AM, Adam <astegman-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > On Wed, Sep 8, 2010 at 10:49 PM, radhames brito <rbritom-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > true is a :get not a :post( typo maybe i was thinking :get but wrote :post), but it is a member action because only one name will be returned, note that he is checking if the is more than one book with that name if that is the case he will not allow the creation so there should never be more than one and the action will only return one record > > A member action acts on a single member. How can you act on an unknown member? > > > resources :titles do > > member do > > get :search > > end > > end > would create a URL like: > /titles/:id/search > What would you suggest putting as the ID? > > Instead, this is acting upon the /titles collection of resources, searching for something that exists within it. As such, the URL would be: > /titles/search > > Adam Stegman > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 9 September 2010 05:09, Anthony Smith <anthony-pO6LffClugqiCYHjmAE91gC/G2K4zDHf@public.gmane.org> wrote:> Okay, I think I''m getting caught up on the resources. I''ll look more into > that for the time being. > Thanks a lot for you help!One further point, the code for the search itself should probably be a class member of the model (or possibly a named scope if it is trivial). Call this from the controller. This keeps business logic out of the controller. Colin -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.