My question pertains to a Rails naming convention conundrum. My application has sign up, sign in, sign out features.
For the sign up page, I used form_for(@user) helper.
For the sign in page I used a form_for(:session, url: sessions_path). But in my routes.rb file I have included the resources :sessions instead of the singular as mentioned in the argument of form_for helper in the sign in page.
If someone could:
1.) Solve this particular form_for issue
2.) More importantly point me in the direction where I can learn/read about Rails naming conventions, I would be highly indebted.
User.new– this is a new user. When you sign up you want to create a new user so you can translate form_for(@user) as “form for a new user”. Note that in this case you provide form_for an ActiveRecord User instance, which is the way it was meant to be used.<%= f.text :name %>in your form it will generate<input name="session[name]" type="text">. Also, when an existing user signs in you do not want to create a new user(like in step 1), you just want to create a new session for an existing user, thus posting to sessions_path looks very intuitive.rake routesin your terminal and get all the named routes set for your application, this will give you a very good insight of how rails converts the resources command into named routes.For further info read the following:
Rails Routing Guide
form_for ApiDock documentation