Reputation: 227
I works fine on my view page:
<%
me = Users.find(session[:id])
%>
<h1>Edit account</h1>
<form action="" method="post">
Username: <input type="text" name="username" value="<%=me[:username]%>" /> <br />
E-mail: <input type="text" name="email" value="<%=me[:email]%>" /><br />
<input type="submit" value="Update" />
</form>
But when i submit the forms i get No route matches [POST] "/account/edit"
My controller:
class AccountController < ApplicationController
def edit
if params[:username]
@out = "Hey"
end
end
end
In routes i tried setting this
post "account/edit"
it did also work, but then the session does not work when it refresh, so getting this:
Couldn't find Users without an ID
Can someone help me
Upvotes: 0
Views: 200
Reputation: 8202
EDITING old response:
I think that trying to debug what you have here is not getting anywhere. The key is there are a lot of problems with your code here and it's not clear what else you have in place that this is interacting with. If you have no other routes set and no other actions in your controller, what is the POST interacting with? Where is a create (or similar) action finding the User to get the user ID for which it's creating an account?
I think you need to run the scaffolding as a starting point
rails g scaffold account attr1:type attr2:type etc.
This will give you something solid you can look at, customize and learn from. I encourage you to keep trying - it's clear you are wanting to learn. Good luck with that! :-)
Upvotes: 1