ok, so here''s my problem... i''ll add the code below... I want to display users, and as an administrator, give other users administrative priviledges... so, I would perform this in the users index page... displaying all users and adding a checkbox next to each one to give administrative priviledges... I''ve tried two methods to do this, the first is submit_tag, and the second is link_to... When I use submit_tag, then theoretically the boolean value for ''administrator'' in the database should be updated, but it''s not... when I use link_to, the page is updated (i.e. the checkbox shows the correct value), but the database is not... also, i''m not redirected to where i''m intended... in the ''update'' action of the controller, I''ve put: format.html { redirect_to(:controller => "videos") } but I get redirected to ''/users/:id'', with the id of the user i''ve just edited... why is this? anyway, here''s the /users/index.html.erb code, i''ve been stumped on this for a while now, and haven''t been able to find anything via google... any help appreciated... cheers! <h1>users</h1> <table> <tr> <th>Login</th> <th>Email</th> <th>Administrator</th> </tr> <% @users.each do |user| %> <tr> <td><%=h user.login %></td> <td><%=h user.email %></td> <% form_for user do |f| %> <% if logged_in? && current_user.administrator? %> <td> <%= f.check_box :administrator %></p> </td> <% end %> <div id="functions"> <td><%= link_to ''Delete'', user, :confirm => ''Are you sure?'', :method => :delete %></td> <td><%= link_to ''Save'', user, :action => :update %></td> </div> <!--<td> <p><%= submit_tag ''Save'' %></p> </td>--> <% end %> </tr> <% end %> </table> --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
the problem is more likely in the controller, so please post that code Is the right method called? You can see that in the development.log file There you can see too, if the params are posted correct --~--~---------~--~----~------------~-------~--~----~ 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 Dec 3, 6:05 pm, Nellboy <nell...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> ok, so here''s my problem... i''ll add the code below... I want to > display users, and as an administrator, give other users > administrative priviledges... so, I would perform this in the users > index page... displaying all users and adding a checkbox next to each > one to give administrative priviledges... > > I''ve tried two methods to do this, the first is submit_tag, and the > second is link_to... When I use submit_tag, then theoretically the > boolean value for ''administrator'' in the database should be updated, > but it''s not... when I use link_to, the page is updated (i.e. the > checkbox shows the correct value), but the database is not... also, > i''m not redirected to where i''m intended... in the ''update'' action of > the controller, I''ve put: > > format.html { redirect_to(:controller => "videos") } > > but I get redirected to ''/users/:id'', with the id of the user i''ve > just edited... why is this? > > anyway, here''s the /users/index.html.erb code, i''ve been stumped on > this for a while now, and haven''t been able to find anything via > google... any help appreciated... cheers! > > <h1>users</h1> > <table> > <tr> > <th>Login</th> > <th>Email</th> > <th>Administrator</th> > </tr> > <% @users.each do |user| %> > <tr> > <td><%=h user.login %></td> > <td><%=h user.email %></td> > > <% form_for user do |f| %> > <% if logged_in? && current_user.administrator? %> > <td> > <%= f.check_box :administrator %></p> > </td> > <% end %> > <div id="functions"> > <td><%= link_to ''Delete'', user, :confirm => ''Are you sure?'', > :method => :delete %></td> > <td><%= link_to ''Save'', user, :action => :update %></td> > </div> > <!--<td> > <p><%= submit_tag ''Save'' %></p> > </td>--> > <% end %> > </tr> > <% end %> > </table>Hello, While submit a form, you should not use ''link_to'' method which will not submit a form actually. It will simply make a request. You should use submit_tag. With submit_tag your code was not working because you have to mention, which action should request go when submit a form. You have not mentioned any action. So, it''s submitting the form to the current uri which is default one. Thus, database is not getting updated. try something like in the below reference http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html Thanks, Sadeesh. --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks Sadeesh so you''re saying I should use something like: <p><%= submit_tag ''Save'' :action => update %></p> On Dec 3, 1:26 pm, sadeesh kumar <sadath...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Dec 3, 6:05 pm, Nellboy <nell...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > ok, so here''s my problem... i''ll add the code below... I want to > > display users, and as an administrator, give other users > > administrative priviledges... so, I would perform this in the users > > index page... displaying all users and adding a checkbox next to each > > one to give administrative priviledges... > > > I''ve tried two methods to do this, the first is submit_tag, and the > > second is link_to... When I use submit_tag, then theoretically the > > boolean value for ''administrator'' in the database should be updated, > > but it''s not... when I use link_to, the page is updated (i.e. the > > checkbox shows the correct value), but the database is not... also, > > i''m not redirected to where i''m intended... in the ''update'' action of > > the controller, I''ve put: > > > format.html { redirect_to(:controller => "videos") } > > > but I get redirected to ''/users/:id'', with the id of the user i''ve > > just edited... why is this? > > > anyway, here''s the /users/index.html.erb code, i''ve been stumped on > > this for a while now, and haven''t been able to find anything via > > google... any help appreciated... cheers! > > > <h1>users</h1> > > <table> > > <tr> > > <th>Login</th> > > <th>Email</th> > > <th>Administrator</th> > > </tr> > > <% @users.each do |user| %> > > <tr> > > <td><%=h user.login %></td> > > <td><%=h user.email %></td> > > > <% form_for user do |f| %> > > <% if logged_in? && current_user.administrator? %> > > <td> > > <%= f.check_box :administrator %></p> > > </td> > > <% end %> > > <div id="functions"> > > <td><%= link_to ''Delete'', user, :confirm => ''Are you sure?'', > > :method => :delete %></td> > > <td><%= link_to ''Save'', user, :action => :update %></td> > > </div> > > <!--<td> > > <p><%= submit_tag ''Save'' %></p> > > </td>--> > > <% end %> > > </tr> > > <% end %> > > </table> > > Hello, > While submit a form, you should not use ''link_to'' method which > will not submit a form actually. It will simply make a request. You > should use submit_tag. With submit_tag your code was not working > because you have to mention, which action should request go when > submit a form. You have not mentioned any action. So, it''s submitting > the form to the current uri which is default one. Thus, database is > not getting updated. try something like in the below reference > > http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html > > Thanks, > Sadeesh.--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
No, I am saying something like <% form_for :person, :url => { :action => "update" } do |f| %> Got it, Yup. On Dec 3, 6:31 pm, Nellboy <nell...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Thanks Sadeesh > > so you''re saying I should use something like: > > <p><%= submit_tag ''Save'' :action => update %></p> > > On Dec 3, 1:26 pm, sadeesh kumar <sadath...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > On Dec 3, 6:05 pm, Nellboy <nell...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > ok, so here''s my problem... i''ll add the code below... I want to > > > display users, and as an administrator, give other users > > > administrative priviledges... so, I would perform this in the users > > > index page... displaying all users and adding a checkbox next to each > > > one to give administrative priviledges... > > > > I''ve tried two methods to do this, the first is submit_tag, and the > > > second is link_to... When I use submit_tag, then theoretically the > > > boolean value for ''administrator'' in the database should be updated, > > > but it''s not... when I use link_to, the page is updated (i.e. the > > > checkbox shows the correct value), but the database is not... also, > > > i''m not redirected to where i''m intended... in the ''update'' action of > > > the controller, I''ve put: > > > > format.html { redirect_to(:controller => "videos") } > > > > but I get redirected to ''/users/:id'', with the id of the user i''ve > > > just edited... why is this? > > > > anyway, here''s the /users/index.html.erb code, i''ve been stumped on > > > this for a while now, and haven''t been able to find anything via > > > google... any help appreciated... cheers! > > > > <h1>users</h1> > > > <table> > > > <tr> > > > <th>Login</th> > > > <th>Email</th> > > > <th>Administrator</th> > > > </tr> > > > <% @users.each do |user| %> > > > <tr> > > > <td><%=h user.login %></td> > > > <td><%=h user.email %></td> > > > > <% form_for user do |f| %> > > > <% if logged_in? && current_user.administrator? %> > > > <td> > > > <%= f.check_box :administrator %></p> > > > </td> > > > <% end %> > > > <div id="functions"> > > > <td><%= link_to ''Delete'', user, :confirm => ''Are you sure?'', > > > :method => :delete %></td> > > > <td><%= link_to ''Save'', user, :action => :update %></td> > > > </div> > > > <!--<td> > > > <p><%= submit_tag ''Save'' %></p> > > > </td>--> > > > <% end %> > > > </tr> > > > <% end %> > > > </table> > > > Hello, > > While submit a form, you should not use ''link_to'' method which > > will not submit a form actually. It will simply make a request. You > > should use submit_tag. With submit_tag your code was not working > > because you have to mention, which action should request go when > > submit a form. You have not mentioned any action. So, it''s submitting > > the form to the current uri which is default one. Thus, database is > > not getting updated. try something like in the below reference > > >http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html > > > Thanks, > > Sadeesh.--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
ok, so I tried this.... and the redirect in the controller is now working, but the database is not updated... which leads me to the controller code, which must be wrong... here it is: def update @user = User.find(params[:id]) respond_to do |format| if @user.update_attributes(params[:user]) flash[:notice] = ''User was successfully updated.'' format.html { redirect_to(:controller => "videos") } format.xml { head :ok } else flash[:notice] = ''unable to update'' format.html { redirect_to(:controller => "videos") } format.xml { render :xml => @user.errors, :status => :unprocessable_entity } end end end On Dec 3, 1:31 pm, Nellboy <nell...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Thanks Sadeesh > > so you''re saying I should use something like: > > <p><%= submit_tag ''Save'' :action => update %></p> > > On Dec 3, 1:26 pm, sadeesh kumar <sadath...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > On Dec 3, 6:05 pm, Nellboy <nell...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > ok, so here''s my problem... i''ll add the code below... I want to > > > display users, and as an administrator, give other users > > > administrative priviledges... so, I would perform this in the users > > > index page... displaying all users and adding a checkbox next to each > > > one to give administrative priviledges... > > > > I''ve tried two methods to do this, the first is submit_tag, and the > > > second is link_to... When I use submit_tag, then theoretically the > > > boolean value for ''administrator'' in the database should be updated, > > > but it''s not... when I use link_to, the page is updated (i.e. the > > > checkbox shows the correct value), but the database is not... also, > > > i''m not redirected to where i''m intended... in the ''update'' action of > > > the controller, I''ve put: > > > > format.html { redirect_to(:controller => "videos") } > > > > but I get redirected to ''/users/:id'', with the id of the user i''ve > > > just edited... why is this? > > > > anyway, here''s the /users/index.html.erb code, i''ve been stumped on > > > this for a while now, and haven''t been able to find anything via > > > google... any help appreciated... cheers! > > > > <h1>users</h1> > > > <table> > > > <tr> > > > <th>Login</th> > > > <th>Email</th> > > > <th>Administrator</th> > > > </tr> > > > <% @users.each do |user| %> > > > <tr> > > > <td><%=h user.login %></td> > > > <td><%=h user.email %></td> > > > > <% form_for user do |f| %> > > > <% if logged_in? && current_user.administrator? %> > > > <td> > > > <%= f.check_box :administrator %></p> > > > </td> > > > <% end %> > > > <div id="functions"> > > > <td><%= link_to ''Delete'', user, :confirm => ''Are you sure?'', > > > :method => :delete %></td> > > > <td><%= link_to ''Save'', user, :action => :update %></td> > > > </div> > > > <!--<td> > > > <p><%= submit_tag ''Save'' %></p> > > > </td>--> > > > <% end %> > > > </tr> > > > <% end %> > > > </table> > > > Hello, > > While submit a form, you should not use ''link_to'' method which > > will not submit a form actually. It will simply make a request. You > > should use submit_tag. With submit_tag your code was not working > > because you have to mention, which action should request go when > > submit a form. You have not mentioned any action. So, it''s submitting > > the form to the current uri which is default one. Thus, database is > > not getting updated. try something like in the below reference > > >http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html > > > Thanks, > > Sadeesh.--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Really, Do you have field name administrator in user table? On Dec 3, 6:42 pm, Nellboy <nell...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> ok, so I tried this.... and the redirect in the controller is now > working, but the database is not updated... which leads me to the > controller code, which must be wrong... here it is: > > def update > @user = User.find(params[:id]) > respond_to do |format| > if @user.update_attributes(params[:user]) > flash[:notice] = ''User was successfully updated.'' > format.html { redirect_to(:controller => "videos") } > format.xml { head :ok } > else > flash[:notice] = ''unable to update'' > format.html { redirect_to(:controller => "videos") } > format.xml { render :xml => @user.errors, > :status => :unprocessable_entity } > end > end > end > > On Dec 3, 1:31 pm, Nellboy <nell...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Thanks Sadeesh > > > so you''re saying I should use something like: > > > <p><%= submit_tag ''Save'' :action => update %></p> > > > On Dec 3, 1:26 pm, sadeesh kumar <sadath...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > On Dec 3, 6:05 pm, Nellboy <nell...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > ok, so here''s my problem... i''ll add the code below... I want to > > > > display users, and as an administrator, give other users > > > > administrative priviledges... so, I would perform this in the users > > > > index page... displaying all users and adding a checkbox next to each > > > > one to give administrative priviledges... > > > > > I''ve tried two methods to do this, the first is submit_tag, and the > > > > second is link_to... When I use submit_tag, then theoretically the > > > > boolean value for ''administrator'' in the database should be updated, > > > > but it''s not... when I use link_to, the page is updated (i.e. the > > > > checkbox shows the correct value), but the database is not... also, > > > > i''m not redirected to where i''m intended... in the ''update'' action of > > > > the controller, I''ve put: > > > > > format.html { redirect_to(:controller => "videos") } > > > > > but I get redirected to ''/users/:id'', with the id of the user i''ve > > > > just edited... why is this? > > > > > anyway, here''s the /users/index.html.erb code, i''ve been stumped on > > > > this for a while now, and haven''t been able to find anything via > > > > google... any help appreciated... cheers! > > > > > <h1>users</h1> > > > > <table> > > > > <tr> > > > > <th>Login</th> > > > > <th>Email</th> > > > > <th>Administrator</th> > > > > </tr> > > > > <% @users.each do |user| %> > > > > <tr> > > > > <td><%=h user.login %></td> > > > > <td><%=h user.email %></td> > > > > > <% form_for user do |f| %> > > > > <% if logged_in? && current_user.administrator? %> > > > > <td> > > > > <%= f.check_box :administrator %></p> > > > > </td> > > > > <% end %> > > > > <div id="functions"> > > > > <td><%= link_to ''Delete'', user, :confirm => ''Are you sure?'', > > > > :method => :delete %></td> > > > > <td><%= link_to ''Save'', user, :action => :update %></td> > > > > </div> > > > > <!--<td> > > > > <p><%= submit_tag ''Save'' %></p> > > > > </td>--> > > > > <% end %> > > > > </tr> > > > > <% end %> > > > > </table> > > > > Hello, > > > While submit a form, you should not use ''link_to'' method which > > > will not submit a form actually. It will simply make a request. You > > > should use submit_tag. With submit_tag your code was not working > > > because you have to mention, which action should request go when > > > submit a form. You have not mentioned any action. So, it''s submitting > > > the form to the current uri which is default one. Thus, database is > > > not getting updated. try something like in the below reference > > > >http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html > > > > Thanks, > > > Sadeesh.--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi Sadeesh... thanks for your help I tried this, and got an error when I tried to update: "Couldn''t find User with ID=update" so I modified the code to: <% form_for user, :url => { :action => "update", :id = user.id } do | f| %> and I got the same result as before... I''m thinking The problem is probably with the users_controller :update action... which i''ve posted on this thread... I''ll continue to investigate thanks again On Dec 3, 1:34 pm, sadeesh kumar viswanathan <sadath...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> No, > I am saying something like > > <% form_for :person, :url => { :action => "update" } do |f| %> > > Got it, > Yup. > > On Dec 3, 6:31 pm, Nellboy <nell...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Thanks Sadeesh > > > so you''re saying I should use something like: > > > <p><%= submit_tag ''Save'' :action => update %></p> > > > On Dec 3, 1:26 pm, sadeesh kumar <sadath...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > On Dec 3, 6:05 pm, Nellboy <nell...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > ok, so here''s my problem... i''ll add the code below... I want to > > > > display users, and as an administrator, give other users > > > > administrative priviledges... so, I would perform this in the users > > > > index page... displaying all users and adding a checkbox next to each > > > > one to give administrative priviledges... > > > > > I''ve tried two methods to do this, the first is submit_tag, and the > > > > second is link_to... When I use submit_tag, then theoretically the > > > > boolean value for ''administrator'' in the database should be updated, > > > > but it''s not... when I use link_to, the page is updated (i.e. the > > > > checkbox shows the correct value), but the database is not... also, > > > > i''m not redirected to where i''m intended... in the ''update'' action of > > > > the controller, I''ve put: > > > > > format.html { redirect_to(:controller => "videos") } > > > > > but I get redirected to ''/users/:id'', with the id of the user i''ve > > > > just edited... why is this? > > > > > anyway, here''s the /users/index.html.erb code, i''ve been stumped on > > > > this for a while now, and haven''t been able to find anything via > > > > google... any help appreciated... cheers! > > > > > <h1>users</h1> > > > > <table> > > > > <tr> > > > > <th>Login</th> > > > > <th>Email</th> > > > > <th>Administrator</th> > > > > </tr> > > > > <% @users.each do |user| %> > > > > <tr> > > > > <td><%=h user.login %></td> > > > > <td><%=h user.email %></td> > > > > > <% form_for user do |f| %> > > > > <% if logged_in? && current_user.administrator? %> > > > > <td> > > > > <%= f.check_box :administrator %></p> > > > > </td> > > > > <% end %> > > > > <div id="functions"> > > > > <td><%= link_to ''Delete'', user, :confirm => ''Are you sure?'', > > > > :method => :delete %></td> > > > > <td><%= link_to ''Save'', user, :action => :update %></td> > > > > </div> > > > > <!--<td> > > > > <p><%= submit_tag ''Save'' %></p> > > > > </td>--> > > > > <% end %> > > > > </tr> > > > > <% end %> > > > > </table> > > > > Hello, > > > While submit a form, you should not use ''link_to'' method which > > > will not submit a form actually. It will simply make a request. You > > > should use submit_tag. With submit_tag your code was not working > > > because you have to mention, which action should request go when > > > submit a form. You have not mentioned any action. So, it''s submitting > > > the form to the current uri which is default one. Thus, database is > > > not getting updated. try something like in the below reference > > > >http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html > > > > Thanks, > > > Sadeesh.--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
yes, a boolean field... On Dec 3, 1:49 pm, sadeesh kumar viswanathan <sadath...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Really, Do you have field name administrator in user table? > > On Dec 3, 6:42 pm, Nellboy <nell...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > ok, so I tried this.... and the redirect in the controller is now > > working, but the database is not updated... which leads me to the > > controller code, which must be wrong... here it is: > > > def update > > @user = User.find(params[:id]) > > respond_to do |format| > > if @user.update_attributes(params[:user]) > > flash[:notice] = ''User was successfully updated.'' > > format.html { redirect_to(:controller => "videos") } > > format.xml { head :ok } > > else > > flash[:notice] = ''unable to update'' > > format.html { redirect_to(:controller => "videos") } > > format.xml { render :xml => @user.errors, > > :status => :unprocessable_entity } > > end > > end > > end > > > On Dec 3, 1:31 pm, Nellboy <nell...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Thanks Sadeesh > > > > so you''re saying I should use something like: > > > > <p><%= submit_tag ''Save'' :action => update %></p> > > > > On Dec 3, 1:26 pm, sadeesh kumar <sadath...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > On Dec 3, 6:05 pm, Nellboy <nell...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > ok, so here''s my problem... i''ll add the code below... I want to > > > > > display users, and as an administrator, give other users > > > > > administrative priviledges... so, I would perform this in the users > > > > > index page... displaying all users and adding a checkbox next to each > > > > > one to give administrative priviledges... > > > > > > I''ve tried two methods to do this, the first is submit_tag, and the > > > > > second is link_to... When I use submit_tag, then theoretically the > > > > > boolean value for ''administrator'' in the database should be updated, > > > > > but it''s not... when I use link_to, the page is updated (i.e. the > > > > > checkbox shows the correct value), but the database is not... also, > > > > > i''m not redirected to where i''m intended... in the ''update'' action of > > > > > the controller, I''ve put: > > > > > > format.html { redirect_to(:controller => "videos") } > > > > > > but I get redirected to ''/users/:id'', with the id of the user i''ve > > > > > just edited... why is this? > > > > > > anyway, here''s the /users/index.html.erb code, i''ve been stumped on > > > > > this for a while now, and haven''t been able to find anything via > > > > > google... any help appreciated... cheers! > > > > > > <h1>users</h1> > > > > > <table> > > > > > <tr> > > > > > <th>Login</th> > > > > > <th>Email</th> > > > > > <th>Administrator</th> > > > > > </tr> > > > > > <% @users.each do |user| %> > > > > > <tr> > > > > > <td><%=h user.login %></td> > > > > > <td><%=h user.email %></td> > > > > > > <% form_for user do |f| %> > > > > > <% if logged_in? && current_user.administrator? %> > > > > > <td> > > > > > <%= f.check_box :administrator %></p> > > > > > </td> > > > > > <% end %> > > > > > <div id="functions"> > > > > > <td><%= link_to ''Delete'', user, :confirm => ''Are you sure?'', > > > > > :method => :delete %></td> > > > > > <td><%= link_to ''Save'', user, :action => :update %></td> > > > > > </div> > > > > > <!--<td> > > > > > <p><%= submit_tag ''Save'' %></p> > > > > > </td>--> > > > > > <% end %> > > > > > </tr> > > > > > <% end %> > > > > > </table> > > > > > Hello, > > > > While submit a form, you should not use ''link_to'' method which > > > > will not submit a form actually. It will simply make a request. You > > > > should use submit_tag. With submit_tag your code was not working > > > > because you have to mention, which action should request go when > > > > submit a form. You have not mentioned any action. So, it''s submitting > > > > the form to the current uri which is default one. Thus, database is > > > > not getting updated. try something like in the below reference > > > > >http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html > > > > > Thanks, > > > > Sadeesh.--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
then check whats there in params[:user][:administrator] when you submit the form and go with it. On Dec 3, 6:52 pm, Nellboy <nell...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> yes, a boolean field... > > On Dec 3, 1:49 pm, sadeesh kumar viswanathan <sadath...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > > Really, Do you have field name administrator in user table? > > > On Dec 3, 6:42 pm, Nellboy <nell...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > ok, so I tried this.... and the redirect in the controller is now > > > working, but the database is not updated... which leads me to the > > > controller code, which must be wrong... here it is: > > > > def update > > > @user = User.find(params[:id]) > > > respond_to do |format| > > > if @user.update_attributes(params[:user]) > > > flash[:notice] = ''User was successfully updated.'' > > > format.html { redirect_to(:controller => "videos") } > > > format.xml { head :ok } > > > else > > > flash[:notice] = ''unable to update'' > > > format.html { redirect_to(:controller => "videos") } > > > format.xml { render :xml => @user.errors, > > > :status => :unprocessable_entity } > > > end > > > end > > > end > > > > On Dec 3, 1:31 pm, Nellboy <nell...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Thanks Sadeesh > > > > > so you''re saying I should use something like: > > > > > <p><%= submit_tag ''Save'' :action => update %></p> > > > > > On Dec 3, 1:26 pm, sadeesh kumar <sadath...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > On Dec 3, 6:05 pm, Nellboy <nell...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > ok, so here''s my problem... i''ll add the code below... I want to > > > > > > display users, and as an administrator, give other users > > > > > > administrative priviledges... so, I would perform this in the users > > > > > > index page... displaying all users and adding a checkbox next to each > > > > > > one to give administrative priviledges... > > > > > > > I''ve tried two methods to do this, the first is submit_tag, and the > > > > > > second is link_to... When I use submit_tag, then theoretically the > > > > > > boolean value for ''administrator'' in the database should be updated, > > > > > > but it''s not... when I use link_to, the page is updated (i.e. the > > > > > > checkbox shows the correct value), but the database is not... also, > > > > > > i''m not redirected to where i''m intended... in the ''update'' action of > > > > > > the controller, I''ve put: > > > > > > > format.html { redirect_to(:controller => "videos") } > > > > > > > but I get redirected to ''/users/:id'', with the id of the user i''ve > > > > > > just edited... why is this? > > > > > > > anyway, here''s the /users/index.html.erb code, i''ve been stumped on > > > > > > this for a while now, and haven''t been able to find anything via > > > > > > google... any help appreciated... cheers! > > > > > > > <h1>users</h1> > > > > > > <table> > > > > > > <tr> > > > > > > <th>Login</th> > > > > > > <th>Email</th> > > > > > > <th>Administrator</th> > > > > > > </tr> > > > > > > <% @users.each do |user| %> > > > > > > <tr> > > > > > > <td><%=h user.login %></td> > > > > > > <td><%=h user.email %></td> > > > > > > > <% form_for user do |f| %> > > > > > > <% if logged_in? && current_user.administrator? %> > > > > > > <td> > > > > > > <%= f.check_box :administrator %></p> > > > > > > </td> > > > > > > <% end %> > > > > > > <div id="functions"> > > > > > > <td><%= link_to ''Delete'', user, :confirm => ''Are you sure?'', > > > > > > :method => :delete %></td> > > > > > > <td><%= link_to ''Save'', user, :action => :update %></td> > > > > > > </div> > > > > > > <!--<td> > > > > > > <p><%= submit_tag ''Save'' %></p> > > > > > > </td>--> > > > > > > <% end %> > > > > > > </tr> > > > > > > <% end %> > > > > > > </table> > > > > > > Hello, > > > > > While submit a form, you should not use ''link_to'' method which > > > > > will not submit a form actually. It will simply make a request. You > > > > > should use submit_tag. With submit_tag your code was not working > > > > > because you have to mention, which action should request go when > > > > > submit a form. You have not mentioned any action. So, it''s submitting > > > > > the form to the current uri which is default one. Thus, database is > > > > > not getting updated. try something like in the below reference > > > > > >http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html > > > > > > Thanks, > > > > > Sadeesh.--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
ok, so i''ve done that... and it seems to be submitting a ''false'' value no matter what I click on... the problem could well be with the following line, maybe it needs some extra options set: <%= f.check_box :administrator %></p> On Dec 3, 1:58 pm, sadeesh kumar viswanathan <sadath...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> then check whats there in params[:user][:administrator] when you > submit the form and go with it. > > On Dec 3, 6:52 pm, Nellboy <nell...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > yes, a boolean field... > > > On Dec 3, 1:49 pm, sadeesh kumar viswanathan <sadath...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > wrote: > > > > Really, Do you have field name administrator in user table? > > > > On Dec 3, 6:42 pm, Nellboy <nell...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > ok, so I tried this.... and the redirect in the controller is now > > > > working, but the database is not updated... which leads me to the > > > > controller code, which must be wrong... here it is: > > > > > def update > > > > @user = User.find(params[:id]) > > > > respond_to do |format| > > > > if @user.update_attributes(params[:user]) > > > > flash[:notice] = ''User was successfully updated.'' > > > > format.html { redirect_to(:controller => "videos") } > > > > format.xml { head :ok } > > > > else > > > > flash[:notice] = ''unable to update'' > > > > format.html { redirect_to(:controller => "videos") } > > > > format.xml { render :xml => @user.errors, > > > > :status => :unprocessable_entity } > > > > end > > > > end > > > > end > > > > > On Dec 3, 1:31 pm, Nellboy <nell...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > Thanks Sadeesh > > > > > > so you''re saying I should use something like: > > > > > > <p><%= submit_tag ''Save'' :action => update %></p> > > > > > > On Dec 3, 1:26 pm, sadeesh kumar <sadath...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > On Dec 3, 6:05 pm, Nellboy <nell...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > ok, so here''s my problem... i''ll add the code below... I want to > > > > > > > display users, and as an administrator, give other users > > > > > > > administrative priviledges... so, I would perform this in the users > > > > > > > index page... displaying all users and adding a checkbox next to each > > > > > > > one to give administrative priviledges... > > > > > > > > I''ve tried two methods to do this, the first is submit_tag, and the > > > > > > > second is link_to... When I use submit_tag, then theoretically the > > > > > > > boolean value for ''administrator'' in the database should be updated, > > > > > > > but it''s not... when I use link_to, the page is updated (i.e. the > > > > > > > checkbox shows the correct value), but the database is not... also, > > > > > > > i''m not redirected to where i''m intended... in the ''update'' action of > > > > > > > the controller, I''ve put: > > > > > > > > format.html { redirect_to(:controller => "videos") } > > > > > > > > but I get redirected to ''/users/:id'', with the id of the user i''ve > > > > > > > just edited... why is this? > > > > > > > > anyway, here''s the /users/index.html.erb code, i''ve been stumped on > > > > > > > this for a while now, and haven''t been able to find anything via > > > > > > > google... any help appreciated... cheers! > > > > > > > > <h1>users</h1> > > > > > > > <table> > > > > > > > <tr> > > > > > > > <th>Login</th> > > > > > > > <th>Email</th> > > > > > > > <th>Administrator</th> > > > > > > > </tr> > > > > > > > <% @users.each do |user| %> > > > > > > > <tr> > > > > > > > <td><%=h user.login %></td> > > > > > > > <td><%=h user.email %></td> > > > > > > > > <% form_for user do |f| %> > > > > > > > <% if logged_in? && current_user.administrator? %> > > > > > > > <td> > > > > > > > <%= f.check_box :administrator %></p> > > > > > > > </td> > > > > > > > <% end %> > > > > > > > <div id="functions"> > > > > > > > <td><%= link_to ''Delete'', user, :confirm => ''Are you sure?'', > > > > > > > :method => :delete %></td> > > > > > > > <td><%= link_to ''Save'', user, :action => :update %></td> > > > > > > > </div> > > > > > > > <!--<td> > > > > > > > <p><%= submit_tag ''Save'' %></p> > > > > > > > </td>--> > > > > > > > <% end %> > > > > > > > </tr> > > > > > > > <% end %> > > > > > > > </table> > > > > > > > Hello, > > > > > > While submit a form, you should not use ''link_to'' method which > > > > > > will not submit a form actually. It will simply make a request. You > > > > > > should use submit_tag. With submit_tag your code was not working > > > > > > because you have to mention, which action should request go when > > > > > > submit a form. You have not mentioned any action. So, it''s submitting > > > > > > the form to the current uri which is default one. Thus, database is > > > > > > not getting updated. try something like in the below reference > > > > > > >http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html > > > > > > > Thanks, > > > > > > Sadeesh.--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hey, try this <%=f.check_box(:administrator, options = {}, checked_value = true, unchecked_value = false)%> On Dec 3, 7:23 pm, Nellboy <nell...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> ok, so i''ve done that... and it seems to be submitting a ''false'' value > no matter what I click on... > > the problem could well be with the following line, maybe it needs some > extra options set: > > <%= f.check_box :administrator %></p> > > On Dec 3, 1:58 pm, sadeesh kumar viswanathan <sadath...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > > then check whats there in params[:user][:administrator] when you > > submit the form and go with it. > > > On Dec 3, 6:52 pm, Nellboy <nell...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > yes, a boolean field... > > > > On Dec 3, 1:49 pm, sadeesh kumar viswanathan <sadath...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > > wrote: > > > > > Really, Do you have field name administrator in user table? > > > > > On Dec 3, 6:42 pm, Nellboy <nell...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > ok, so I tried this.... and the redirect in the controller is now > > > > > working, but the database is not updated... which leads me to the > > > > > controller code, which must be wrong... here it is: > > > > > > def update > > > > > @user = User.find(params[:id]) > > > > > respond_to do |format| > > > > > if @user.update_attributes(params[:user]) > > > > > flash[:notice] = ''User was successfully updated.'' > > > > > format.html { redirect_to(:controller => "videos") } > > > > > format.xml { head :ok } > > > > > else > > > > > flash[:notice] = ''unable to update'' > > > > > format.html { redirect_to(:controller => "videos") } > > > > > format.xml { render :xml => @user.errors, > > > > > :status => :unprocessable_entity } > > > > > end > > > > > end > > > > > end > > > > > > On Dec 3, 1:31 pm, Nellboy <nell...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > Thanks Sadeesh > > > > > > > so you''re saying I should use something like: > > > > > > > <p><%= submit_tag ''Save'' :action => update %></p> > > > > > > > On Dec 3, 1:26 pm, sadeesh kumar <sadath...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > On Dec 3, 6:05 pm, Nellboy <nell...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > > ok, so here''s my problem... i''ll add the code below... I want to > > > > > > > > display users, and as an administrator, give other users > > > > > > > > administrative priviledges... so, I would perform this in the users > > > > > > > > index page... displaying all users and adding a checkbox next to each > > > > > > > > one to give administrative priviledges... > > > > > > > > > I''ve tried two methods to do this, the first is submit_tag, and the > > > > > > > > second is link_to... When I use submit_tag, then theoretically the > > > > > > > > boolean value for ''administrator'' in the database should be updated, > > > > > > > > but it''s not... when I use link_to, the page is updated (i.e. the > > > > > > > > checkbox shows the correct value), but the database is not... also, > > > > > > > > i''m not redirected to where i''m intended... in the ''update'' action of > > > > > > > > the controller, I''ve put: > > > > > > > > > format.html { redirect_to(:controller => "videos") } > > > > > > > > > but I get redirected to ''/users/:id'', with the id of the user i''ve > > > > > > > > just edited... why is this? > > > > > > > > > anyway, here''s the /users/index.html.erb code, i''ve been stumped on > > > > > > > > this for a while now, and haven''t been able to find anything via > > > > > > > > google... any help appreciated... cheers! > > > > > > > > > <h1>users</h1> > > > > > > > > <table> > > > > > > > > <tr> > > > > > > > > <th>Login</th> > > > > > > > > <th>Email</th> > > > > > > > > <th>Administrator</th> > > > > > > > > </tr> > > > > > > > > <% @users.each do |user| %> > > > > > > > > <tr> > > > > > > > > <td><%=h user.login %></td> > > > > > > > > <td><%=h user.email %></td> > > > > > > > > > <% form_for user do |f| %> > > > > > > > > <% if logged_in? && current_user.administrator? %> > > > > > > > > <td> > > > > > > > > <%= f.check_box :administrator %></p> > > > > > > > > </td> > > > > > > > > <% end %> > > > > > > > > <div id="functions"> > > > > > > > > <td><%= link_to ''Delete'', user, :confirm => ''Are you sure?'', > > > > > > > > :method => :delete %></td> > > > > > > > > <td><%= link_to ''Save'', user, :action => :update %></td> > > > > > > > > </div> > > > > > > > > <!--<td> > > > > > > > > <p><%= submit_tag ''Save'' %></p> > > > > > > > > </td>--> > > > > > > > > <% end %> > > > > > > > > </tr> > > > > > > > > <% end %> > > > > > > > > </table> > > > > > > > > Hello, > > > > > > > While submit a form, you should not use ''link_to'' method which > > > > > > > will not submit a form actually. It will simply make a request. You > > > > > > > should use submit_tag. With submit_tag your code was not working > > > > > > > because you have to mention, which action should request go when > > > > > > > submit a form. You have not mentioned any action. So, it''s submitting > > > > > > > the form to the current uri which is default one. Thus, database is > > > > > > > not getting updated. try something like in the below reference > > > > > > > >http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html > > > > > > > > Thanks, > > > > > > > Sadeesh.--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
ya, i''ve been playing around with that for a while... i think it''s the issue, but it''s not accepting my submissions... On Dec 3, 2:52 pm, sadeesh kumar viswanathan <sadath...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hey, > try this > > <%=f.check_box(:administrator, options = {}, checked_value = true, > unchecked_value = false)%> > > On Dec 3, 7:23 pm, Nellboy <nell...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > ok, so i''ve done that... and it seems to be submitting a ''false'' value > > no matter what I click on... > > > the problem could well be with the following line, maybe it needs some > > extra options set: > > > <%= f.check_box :administrator %></p> > > > On Dec 3, 1:58 pm, sadeesh kumar viswanathan <sadath...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > wrote: > > > > then check whats there in params[:user][:administrator] when you > > > submit the form and go with it. > > > > On Dec 3, 6:52 pm, Nellboy <nell...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > yes, a boolean field... > > > > > On Dec 3, 1:49 pm, sadeesh kumar viswanathan <sadath...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > > > wrote: > > > > > > Really, Do you have field name administrator in user table? > > > > > > On Dec 3, 6:42 pm, Nellboy <nell...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > ok, so I tried this.... and the redirect in the controller is now > > > > > > working, but the database is not updated... which leads me to the > > > > > > controller code, which must be wrong... here it is: > > > > > > > def update > > > > > > @user = User.find(params[:id]) > > > > > > respond_to do |format| > > > > > > if @user.update_attributes(params[:user]) > > > > > > flash[:notice] = ''User was successfully updated.'' > > > > > > format.html { redirect_to(:controller => "videos") } > > > > > > format.xml { head :ok } > > > > > > else > > > > > > flash[:notice] = ''unable to update'' > > > > > > format.html { redirect_to(:controller => "videos") } > > > > > > format.xml { render :xml => @user.errors, > > > > > > :status => :unprocessable_entity } > > > > > > end > > > > > > end > > > > > > end > > > > > > > On Dec 3, 1:31 pm, Nellboy <nell...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > Thanks Sadeesh > > > > > > > > so you''re saying I should use something like: > > > > > > > > <p><%= submit_tag ''Save'' :action => update %></p> > > > > > > > > On Dec 3, 1:26 pm, sadeesh kumar <sadath...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > > On Dec 3, 6:05 pm, Nellboy <nell...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > > > ok, so here''s my problem... i''ll add the code below... I want to > > > > > > > > > display users, and as an administrator, give other users > > > > > > > > > administrative priviledges... so, I would perform this in the users > > > > > > > > > index page... displaying all users and adding a checkbox next to each > > > > > > > > > one to give administrative priviledges... > > > > > > > > > > I''ve tried two methods to do this, the first is submit_tag, and the > > > > > > > > > second is link_to... When I use submit_tag, then theoretically the > > > > > > > > > boolean value for ''administrator'' in the database should be updated, > > > > > > > > > but it''s not... when I use link_to, the page is updated (i.e. the > > > > > > > > > checkbox shows the correct value), but the database is not... also, > > > > > > > > > i''m not redirected to where i''m intended... in the ''update'' action of > > > > > > > > > the controller, I''ve put: > > > > > > > > > > format.html { redirect_to(:controller => "videos") } > > > > > > > > > > but I get redirected to ''/users/:id'', with the id of the user i''ve > > > > > > > > > just edited... why is this? > > > > > > > > > > anyway, here''s the /users/index.html.erb code, i''ve been stumped on > > > > > > > > > this for a while now, and haven''t been able to find anything via > > > > > > > > > google... any help appreciated... cheers! > > > > > > > > > > <h1>users</h1> > > > > > > > > > <table> > > > > > > > > > <tr> > > > > > > > > > <th>Login</th> > > > > > > > > > <th>Email</th> > > > > > > > > > <th>Administrator</th> > > > > > > > > > </tr> > > > > > > > > > <% @users.each do |user| %> > > > > > > > > > <tr> > > > > > > > > > <td><%=h user.login %></td> > > > > > > > > > <td><%=h user.email %></td> > > > > > > > > > > <% form_for user do |f| %> > > > > > > > > > <% if logged_in? && current_user.administrator? %> > > > > > > > > > <td> > > > > > > > > > <%= f.check_box :administrator %></p> > > > > > > > > > </td> > > > > > > > > > <% end %> > > > > > > > > > <div id="functions"> > > > > > > > > > <td><%= link_to ''Delete'', user, :confirm => ''Are you sure?'', > > > > > > > > > :method => :delete %></td> > > > > > > > > > <td><%= link_to ''Save'', user, :action => :update %></td> > > > > > > > > > </div> > > > > > > > > > <!--<td> > > > > > > > > > <p><%= submit_tag ''Save'' %></p> > > > > > > > > > </td>--> > > > > > > > > > <% end %> > > > > > > > > > </tr> > > > > > > > > > <% end %> > > > > > > > > > </table> > > > > > > > > > Hello, > > > > > > > > While submit a form, you should not use ''link_to'' method which > > > > > > > > will not submit a form actually. It will simply make a request. You > > > > > > > > should use submit_tag. With submit_tag your code was not working > > > > > > > > because you have to mention, which action should request go when > > > > > > > > submit a form. You have not mentioned any action. So, it''s submitting > > > > > > > > the form to the current uri which is default one. Thus, database is > > > > > > > > not getting updated. try something like in the below reference > > > > > > > > >http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html > > > > > > > > > Thanks, > > > > > > > > Sadeesh.--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---