I’m trying to do develop some modules so I can reuse all my codes in
different projects.
I need to put routing in different files, and in route.rb include the
files which have my routing code, but I don’t know if this would work,
and if I could actually do it? any help would be good
Example, this one should be for the account model, are in
route_account.rb.
It’s seeing the class, just not the method. Perhaps you missed my email
about making the method a class method instead of a instance one.
Chalk
all my forgetful little errors this morning to lack of coffee. Or
something.
It’s seeing the class, just not the method. Perhaps you missed my email
about making the method a class method instead of a instance one.
Chalk
all my forgetful little errors this morning to lack of coffee. Or
something.
class RouteAccount
def self.add_routes_to(map)
map.login ‘login’, :controller => ‘accounts’, :action => ‘login’
# I presume the next one should actually be map.signup, not
map.login…
map.login ‘signup’, :controller => ‘accounts’, :action =>
‘signup’
map.logout ‘logout’, :controller => ‘accounts’, :action =>
‘logout’
map.account ‘account’ :controller => ‘accounts’, :action =>
‘account’
end
end
Not only does it work but I’ve got two variations of it working in my
app.
If you’d like, I can help you more but not if you’re insistent on
telling me
that it doesn’t work.
class RouteAccount
def self.add_routes_to(map)
map.login ‘login’, :controller => ‘accounts’, :action => ‘login’
# I presume the next one should actually be map.signup, not .
Not working either, I don’t think it will work, I tried everything?
Not only does it work but I’ve got two variations of it working in my
app.
If you’d like, I can help you more but not if you’re insistent on
telling me
that it doesn’t work.
RSL
Well I’m sorry, I still don’t get it to work
Routing Error
no route found to match “/login” with {:method=>:get}
Can you sent me your files, so I can just replace them with what I have?
which will output a listing of all the routes to the terminal you
started
your server from. You’ll want to comment that out in production mode of
course.
All this code does is take the route map that the Routes.draw
creates/uses
and sends it to a class method which adds routes to it. Nothing weird.
Just
a different place than normally routes are set. I got the idea from
looking
around Mephisto’s source. Rick is so far above me as a programmer that
my
implementation is a lot simpler but basically the same.
RSL
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.