What do I do wrong? map.resources :books def BooksController def create # Code end def index # Code end # Other code end If I make a POST to books_url it calls index. What''s wrong? Regards -- I''ve probably left my head... somewhere. Please wait untill I find it. Homepage (pl_PL): http://uzytkownik.jogger.pl/ (GNU/)Linux User: #425935 (see http://counter.li.org/) --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
First of all shouldn''t that look more like:
class BooksController < ApplicationController
  def create
    # Code
  end
  def index
    # Code
  end
  # Other code
end
Secondly, how are you issuing your POST?
- From a form?
- From the command line using a program like curl or wget?
If you are calling this from a form what does your view code look
like?
Are you really sure you are issuing a POST?  How do you know this?
Are you using a TCP capture application to view the HTTP requests?
On May 21, 5:23 pm, Maciej Piechotka
<uzytkown...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> What do I do wrong?
>
> map.resources :books
>
> def BooksController
>         def create
>                 # Code
>         end
>
>         def index
>                 # Code
>         end
>
>         # Other code
> end
>
> If I make a POST to books_url it calls index. What''s wrong?
>
> Regards
> --
> I''ve probably left my head... somewhere. Please wait untill I find
it.
> Homepage (pl_PL):http://uzytkownik.jogger.pl/
> (GNU/)Linux User: #425935 (seehttp://counter.li.org/)
--~--~---------~--~----~------------~-------~--~----~
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
On Mon, 21 May 2007 16:38:39 -0700, Robert Walker wrote:> First of all shouldn''t that look more like: > > class BooksController < ApplicationController > def create > # Code > end > > def index > # Code > end > > # Other code > end >Yes - sorry. I deleted too much.> Secondly, how are you issuing your POST? - From a form? > - From the command line using a program like curl or wget? >No from browser.> If you are calling this from a form what does your view code look like? ><% remote_form_for :book, :url => books_url, :method => :post do |f| %> <span class="title"><%= f.text_field :title %></span> <span class="subtitle"><%= f.text_field :subtitle %></span> <span class="action0"> <%= submit_tag "Save" %> </span> <% end %>%> Are you really sure you are issuing a POST? How do you know this? Are > you using a TCP capture application to view the HTTP requests? >I believe logs: Processing BooksController#index (for 127.0.0.1 at 2007-05-20 23:16:34) [POST] Session ID: 47fb4fa9620e309c841f699f080e1b99 Parameters: {"commit"=>"Save", "action"=>"index", "controller"=>"books", "book "=>{"title"=>"Test1", "subtitle"=>"Test2"}} Book Load (0.002412) SELECT * FROM books Rendering within layouts/application Rendering books/index Rendered books/_new (0.00332) Completed in 0.56535 (1 reqs/sec) | Rendering: 0.00843 (1%) | DB: 0.00241 (0%) | 200 OK [http://localhost/books] Regards --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I''ve seen this behavior in my own app as well as someone
else''s on
#rubyonrails IRC. I can''t duplicate it though. For my app, I had to end
up
using
form_for :site, :url => "/sites/", :html => {:method =>
:post} do |f|
because :action => :create [on the SitesController] sent the user back to
the index. Hard-coded urls work fine but Rails seems to choke on the proper
route generation. If I recall correctly, all these scenarios were with
RESTful routing but don''t hold me to that. Mine was, for sure, though.
RSL
On 5/22/07, Maciej Piechotka
<uzytkownik2-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:>
>
> On Mon, 21 May 2007 16:38:39 -0700, Robert Walker wrote:
>
> > First of all shouldn''t that look more like:
> >
> > class BooksController < ApplicationController
> >   def create
> >     # Code
> >   end
> >
> >   def index
> >     # Code
> >   end
> >
> >   # Other code
> > end
> >
>
> Yes - sorry. I deleted too much.
>
> > Secondly, how are you issuing your POST? - From a form?
> > - From the command line using a program like curl or wget?
> >
>
> No from browser.
>
> > If you are calling this from a form what does your view code look
like?
> >
>
> <% remote_form_for :book, :url => books_url, :method => :post do
|f| %>
>     <span class="title"><%= f.text_field :title
%></span>
>     <span class="subtitle"><%= f.text_field :subtitle
%></span>
>     <span class="action0">
>         <%= submit_tag "Save" %>
>     </span>
> <% end %>%
>
> > Are you really sure you are issuing a POST?  How do you know this? Are
> > you using a TCP capture application to view the HTTP requests?
> >
>
> I believe logs:
> Processing BooksController#index (for 127.0.0.1 at 2007-05-20 23:16:34)
> [POST]
>   Session ID: 47fb4fa9620e309c841f699f080e1b99
>   Parameters: {"commit"=>"Save",
"action"=>"index",
> "controller"=>"books", "book
> "=>{"title"=>"Test1",
"subtitle"=>"Test2"}}
>   Book Load (0.002412)   SELECT * FROM books
> Rendering  within layouts/application
> Rendering books/index
> Rendered books/_new (0.00332)
> Completed in 0.56535 (1 reqs/sec) | Rendering: 0.00843 (1%) | DB: 0.00241
> (0%) |
> 200 OK [http://localhost/books]
>
> Regards
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
On 5/22/07, Russell Norris <rsl-ftMzyaTR+bHNyFkoKTPOtdi2O/JbrIOy@public.gmane.org> wrote:> I''ve seen this behavior in my own app as well as someone else''s on > #rubyonrails IRC. I can''t duplicate it though. For my app, I had to end up > using > > form_for :site, :url => "/sites/", :html => {:method => :post} do |f| > > because :action => :create [on the SitesController] sent the user back to > the index. Hard-coded urls work fine but Rails seems to choke on the proper > route generation. If I recall correctly, all these scenarios were with > RESTful routing but don''t hold me to that. Mine was, for sure, though.That''s absurd, I don''t use any hardcoded URLs. Make sure your routes file is correct. map.resources should go above the default map.connect call. -- Rick Olson http://lighthouseapp.com http://weblog.techno-weenie.net http://mephistoblog.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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Rick Olson <technoweenie@...> writes:> > > That''s absurd, I don''t use any hardcoded URLs. Make sure your routes > file is correct. map.resources should go above the default map.connect > call. >Thank you. I''ll try it. Where can I find such things because I found it neighter in Rails doc nor in wiki... --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---