johnnybutler7
2013-Nov-08 17:41 UTC
create action, fails validation, renders new and then calls the index action silent the background?
Hi Guys,
Strange issue going on, cant get to the bottom of it.
I have a bog standard form which submits to the create action fine. If the
validation fails however the new action is rendered with the appropriate
errors,
however in the logs i notice the index action is called silently and I can
see the trace of sql, see below:
controller code
def create
@discussion = Discussion.new
@discussion.assign_attributes(params[:discussion].merge(created_by_id:
current_user.id), :as => :admin)
respond_to do |format|
if @discussion.save
format.html { redirect_to discussion_path(@discussion), notice:
"Discussion was successfully created."}
else
format.html { render ''new'' }
end
end
end
Started POST "/discussions" for 127.0.0.1 at 2013-11-08 17:35:29 +0000
Processing by DiscussionsController#create as HTML
Parameters: {"utf8"=>"✓",
"authenticity_token"=>"Xmxr58tjF1TEUUWFL+u3/VNzl/1HM83kAeD60LieP/0=",
"discussion"=>{"title"=>"",
"body"=>"", "user_ids"=>[""]},
"commit"=>"submit"}
[1m [36m (2.3ms) [0m [1mBEGIN [0m
[1m [35m (2.2ms) [0m ROLLBACK
blah blah.....
Rendered discussions/new.html.erb within layouts/launchpad (50.5ms)
Completed 200 OK in 362.0ms (Views: 274.6ms | ActiveRecord: 78.1ms)
Started GET "/discussions" for 127.0.0.1 at 2013-11-08 17:35:30 +0000
Processing by DiscussionsController#index as HTML
[1m [36mUser Load (3.4ms) [0m [1mSELECT "users".* FROM
"users" WHERE
"users"."id" = 8 LIMIT 1 [0m
[1m [35mContext Load (2.4ms) [0m SELECT "contexts".* FROM
"contexts"
WHERE "contexts"."id" = $1 LIMIT 1 [["id",
"2"]]
[1m [36mRole Load (4.3ms) [0m [1mSELECT "roles".* FROM
"roles" WHERE
"roles"."name" = ''PC_USER'' LIMIT 1 [0m
[1m [35mRole Load (3.8ms) [0m SELECT "roles".* FROM
"roles"
Rendered admin/shared/_quick_links.html.erb (2.1ms)
[1m [36mDiscussion Load (3.6ms) [0m [1mSELECT DISTINCT discussions.*
FROM "discussions" INNER JOIN "discussions_users" ON
"discussions_users"."discussion_id" =
"discussions"."id" INNER JOIN "users"
ON "users"."id" =
"discussions_users"."user_id" WHERE (created_by_id = 8 OR
discussions_users.user_id = 8 OR users.account_id = 1) [0m
--
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/00ad49ed-9ffa-49e3-8c8d-046846dd4a39%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Tamara Temple
2013-Nov-09 22:54 UTC
Re: create action, fails validation, renders new and then calls the index action silent the background?
On Nov 8, 2013, at 11:41 AM, johnnybutler7 <johnnybutler7-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi Guys, > > Strange issue going on, cant get to the bottom of it. > > I have a bog standard form which submits to the create action fine. If the validation fails however the new action is rendered with the appropriate errors, > however in the logs i notice the index action is called silently and I can see the trace of sql, see below: > > controller code > > def create > @discussion = Discussion.new > @discussion.assign_attributes(params[:discussion].merge(created_by_id: current_user.id), :as => :admin) > respond_to do |format| > if @discussion.save > format.html { redirect_to discussion_path(@discussion), notice: "Discussion was successfully created."} > else > format.html { render ''new'' } > end > end > end > > Started POST "/discussions" for 127.0.0.1 at 2013-11-08 17:35:29 +0000 > Processing by DiscussionsController#create as HTML > Parameters: {"utf8"=>"✓", "authenticity_token"=>"Xmxr58tjF1TEUUWFL+u3/VNzl/1HM83kAeD60LieP/0=", "discussion"=>{"title"=>"", "body"=>"", "user_ids"=>[""]}, "commit"=>"submit"} > [1m [36m (2.3ms) [0m [1mBEGIN [0m > [1m [35m (2.2ms) [0m ROLLBACK > blah blah..... > Rendered discussions/new.html.erb within layouts/launchpad (50.5ms) > Completed 200 OK in 362.0ms (Views: 274.6ms | ActiveRecord: 78.1ms) > > Started GET "/discussions" for 127.0.0.1 at 2013-11-08 17:35:30 +0000 > Processing by DiscussionsController#index as HTML > [1m [36mUser Load (3.4ms) [0m [1mSELECT "users".* FROM "users" WHERE "users"."id" = 8 LIMIT 1 [0m > [1m [35mContext Load (2.4ms) [0m SELECT "contexts".* FROM "contexts" WHERE "contexts"."id" = $1 LIMIT 1 [["id", "2"]] > [1m [36mRole Load (4.3ms) [0m [1mSELECT "roles".* FROM "roles" WHERE "roles"."name" = ''PC_USER'' LIMIT 1 [0m > [1m [35mRole Load (3.8ms) [0m SELECT "roles".* FROM "roles" > Rendered admin/shared/_quick_links.html.erb (2.1ms) > [1m [36mDiscussion Load (3.6ms) [0m [1mSELECT DISTINCT discussions.* FROM "discussions" INNER JOIN "discussions_users" ON "discussions_users"."discussion_id" = "discussions"."id" INNER JOIN "users" ON "users"."id" = "discussions_users"."user_id" WHERE (created_by_id = 8 OR discussions_users.user_id = 8 OR users.account_id = 1) [0m >The clue might be in what is being rendered in the second request:> Rendered admin/shared/_quick_links.html.erb (2.1ms)Maybe an AJAX request? -- 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/E1EBDBCD-A125-42CF-A4DB-8224CBDF9860%40gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
John Butler
2013-Nov-11 09:16 UTC
Re: create action, fails validation, renders new and then calls the index action silent the background?
thanks for your reply. Yes, thats what i thought originally but firebug wasnt showing any ajax requests. I will have to go through each bit and find out exactly where the request is coming from, probably some javascript somewhere. On Sat, Nov 9, 2013 at 10:54 PM, Tamara Temple <tamouse.lists-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote:> > On Nov 8, 2013, at 11:41 AM, johnnybutler7 <johnnybutler7-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > > Hi Guys, > > > > Strange issue going on, cant get to the bottom of it. > > > > I have a bog standard form which submits to the create action fine. If > the validation fails however the new action is rendered with the > appropriate errors, > > however in the logs i notice the index action is called silently and I > can see the trace of sql, see below: > > > > controller code > > > > def create > > @discussion = Discussion.new > > > @discussion.assign_attributes(params[:discussion].merge(created_by_id: > current_user.id), :as => :admin) > > respond_to do |format| > > if @discussion.save > > format.html { redirect_to discussion_path(@discussion), notice: > "Discussion was successfully created."} > > else > > format.html { render ''new'' } > > end > > end > > end > > > > Started POST "/discussions" for 127.0.0.1 at 2013-11-08 17:35:29 +0000 > > Processing by DiscussionsController#create as HTML > > Parameters: {"utf8"=>"✓", > "authenticity_token"=>"Xmxr58tjF1TEUUWFL+u3/VNzl/1HM83kAeD60LieP/0=", > "discussion"=>{"title"=>"", "body"=>"", "user_ids"=>[""]}, > "commit"=>"submit"} > > [1m [36m (2.3ms) [0m [1mBEGIN [0m > > [1m [35m (2.2ms) [0m ROLLBACK > > blah blah..... > > Rendered discussions/new.html.erb within layouts/launchpad (50.5ms) > > Completed 200 OK in 362.0ms (Views: 274.6ms | ActiveRecord: 78.1ms) > > > > Started GET "/discussions" for 127.0.0.1 at 2013-11-08 17:35:30 +0000 > > Processing by DiscussionsController#index as HTML > > [1m [36mUser Load (3.4ms) [0m [1mSELECT "users".* FROM "users" WHERE > "users"."id" = 8 LIMIT 1 [0m > > [1m [35mContext Load (2.4ms) [0m SELECT "contexts".* FROM "contexts" > WHERE "contexts"."id" = $1 LIMIT 1 [["id", "2"]] > > [1m [36mRole Load (4.3ms) [0m [1mSELECT "roles".* FROM "roles" WHERE > "roles"."name" = ''PC_USER'' LIMIT 1 [0m > > [1m [35mRole Load (3.8ms) [0m SELECT "roles".* FROM "roles" > > Rendered admin/shared/_quick_links.html.erb (2.1ms) > > [1m [36mDiscussion Load (3.6ms) [0m [1mSELECT DISTINCT discussions.* > FROM "discussions" INNER JOIN "discussions_users" ON > "discussions_users"."discussion_id" = "discussions"."id" INNER JOIN "users" > ON "users"."id" = "discussions_users"."user_id" WHERE (created_by_id = 8 OR > discussions_users.user_id = 8 OR users.account_id = 1) [0m > > > > The clue might be in what is being rendered in the second request: > > > Rendered admin/shared/_quick_links.html.erb (2.1ms) > > Maybe an AJAX request? > > > -- > You received this message because you are subscribed to a topic in the > Google Groups "Ruby on Rails: Talk" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/rubyonrails-talk/_sqwOlUJcV4/unsubscribe > . > To unsubscribe from this group and all its topics, 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/E1EBDBCD-A125-42CF-A4DB-8224CBDF9860%40gmail.com > . > For more options, visit https://groups.google.com/groups/opt_out. >-- 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/CAMTDKyVHgc%2BQezNa6Ej95jr3FFMcUrbf2YgR%3DEcD0ewv7T6WWA%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
johnnybutler7
2013-Nov-11 10:05 UTC
Re: create action, fails validation, renders new and then calls the index action silent the background?
turns out it was this line of code in the layout <link REL="SHORTCUT ICON" HREF=""> give me strength! On Friday, November 8, 2013 5:41:28 PM UTC, johnnybutler7 wrote:> > Hi Guys, > > Strange issue going on, cant get to the bottom of it. > > I have a bog standard form which submits to the create action fine. If > the validation fails however the new action is rendered with the > appropriate errors, > however in the logs i notice the index action is called silently and I can > see the trace of sql, see below: > > controller code > > def create > @discussion = Discussion.new > @discussion.assign_attributes(params[:discussion].merge(created_by_id: > current_user.id), :as => :admin) > respond_to do |format| > if @discussion.save > format.html { redirect_to discussion_path(@discussion), notice: > "Discussion was successfully created."} > else > format.html { render ''new'' } > end > end > end > > Started POST "/discussions" for 127.0.0.1 at 2013-11-08 17:35:29 +0000 > Processing by DiscussionsController#create as HTML > Parameters: {"utf8"=>"✓", > "authenticity_token"=>"Xmxr58tjF1TEUUWFL+u3/VNzl/1HM83kAeD60LieP/0=", > "discussion"=>{"title"=>"", "body"=>"", "user_ids"=>[""]}, > "commit"=>"submit"} > [1m [36m (2.3ms) [0m [1mBEGIN [0m > [1m [35m (2.2ms) [0m ROLLBACK > blah blah..... > Rendered discussions/new.html.erb within layouts/launchpad (50.5ms) > Completed 200 OK in 362.0ms (Views: 274.6ms | ActiveRecord: 78.1ms) > > Started GET "/discussions" for 127.0.0.1 at 2013-11-08 17:35:30 +0000 > Processing by DiscussionsController#index as HTML > [1m [36mUser Load (3.4ms) [0m [1mSELECT "users".* FROM "users" WHERE > "users"."id" = 8 LIMIT 1 [0m > [1m [35mContext Load (2.4ms) [0m SELECT "contexts".* FROM "contexts" > WHERE "contexts"."id" = $1 LIMIT 1 [["id", "2"]] > [1m [36mRole Load (4.3ms) [0m [1mSELECT "roles".* FROM "roles" WHERE > "roles"."name" = ''PC_USER'' LIMIT 1 [0m > [1m [35mRole Load (3.8ms) [0m SELECT "roles".* FROM "roles" > Rendered admin/shared/_quick_links.html.erb (2.1ms) > [1m [36mDiscussion Load (3.6ms) [0m [1mSELECT DISTINCT discussions.* > FROM "discussions" INNER JOIN "discussions_users" ON > "discussions_users"."discussion_id" = "discussions"."id" INNER JOIN "users" > ON "users"."id" = "discussions_users"."user_id" WHERE (created_by_id = 8 OR > discussions_users.user_id = 8 OR users.account_id = 1) [0m >-- 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/2722b727-fc82-4d1b-8f32-d9ffe5cbc75e%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.