Re: [Rails] suggest routes.

15 views
Skip to first unread message

Walter Lee Davis

unread,
Oct 15, 2016, 11:40:43 AM10/15/16
to rubyonra...@googlegroups.com

> On Oct 15, 2016, at 3:25 AM, kinoe - <kin...@gmail.com> wrote:
>
> I have routes.rb:
> resources :user
> #that have default
> # path verb
> # user_index get "user#index''
> # post "user#create"
> #new_user get "user#new"
> for moment i using method "new" as new.htmk(form login)&"create" as process get data from db.
> new.html.erb
> <%=form_for :blog,url: user_index_path do lbl%>
> ........
> user_controller.rb
> def new
> @blog = Box.new
> end
> #procces login
> def create
> @b =Box.find_by(search_params)
> .....
> end
> if i try make routes like this
> get '/user/login',to: "user#login"
> that only for view html verb get,how make process it that verb post like deafult routes? thank you.

Start here: http://guides.rubyonrails.org/routing.html

Read that entire page, and try what it suggests. If you have questions after that, post what you tried and what happened when you did so here, and someone can help you.

As a starting hint, the resources helper creates routes for all 7 of the REST actions. It's tightly coupled with a "normal" Rails controller that does CRUD for a table in the database. If your controller is custom, does something other than the usual, then you may need to get out and push, as you have noticed. But actually, if you are finding that to be the case, it may be that you have another path you could follow. user#login might actually be session#new in disguise. There's no particular reason for you to couple login with user, since the user is not modified by being logged in.

Walter

>
> --
> 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-ta...@googlegroups.com.
> To post to this group, send email to rubyonra...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/0081dcc1-7998-497f-988c-12d9c38e8a04%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Colin Law

unread,
Oct 15, 2016, 12:16:58 PM10/15/16
to Ruby on Rails: Talk
Also I think you would benefit from working right through a good tutorial such as railstutorial.org (which is free to use online).

Colin
 
Reply all
Reply to author
Forward
Message has been deleted
Message has been deleted
0 new messages