I’d like to implement (Rails 4) a very high level (generic) abstract
controller, able to manage any route and then create a viewer on the
fly.
I’d like to call it ‘abstracts’, and being able to call as
:abstract(/:subject(/:action(/:id)))
something like
abstract/user/create
or
abstract/identity/:john/edit
I’m not sure on the best way to define the correct route, and how to
generate the model and the view code on the fly, after getting the
definition in the controller from the DB.
When you set up a regular route, you supply a series of symbols that
Rails
maps to parts of an incoming HTTP request. Two of these symbols are
special: :controller maps to the name of a controller in your
application,
and :action maps to the name of an action within that controller. For
example, consider this route:
get ‘:controller(/:action(/:id))’
If an incoming request of /photos/show/1 is processed by this route
(because it hasn’t matched any previous route in the file), then the
result
will be to invoke the show action of the PhotosController, and to make
the
final parameter “1” available as params[:id]. This route will also route
the incoming request of /photos to PhotosController#index, since
:actionand
:id are optional parameters, denoted by parentheses.
the route excepts to get 1-3 parts, separated by / and you are trying
to
get 4 things to match
the real issue, try
<%= link_to “some text”, “factory/demo/user/9” %>
So you had missing ‘)’ and probably next thing it would complain is that
variables/methods factory/demo/user are not found…
On 18 September 2014 22:04, Paolo Di Pietro [email protected]
wrote:
Done!
Then I put
<%= link_to “some text”, /factory/demo/message/1389/ %>
in my .erb file
I think maybe before worrying about generic routes you need to get to
grips
with the basics of ruby and rails. I suggest you start by working right
through a good tutorial such as railstutorial.org (which is free to use
online).
your suggestion is surely correct. My point is that I’m trying to
perform
an over complex task dealing with a lot of new technologies to
integrate.
I need a kick to bypass this stop.
Il giorno giovedì 18 settembre 2014 23:15:54 UTC+2, Colin L. ha
scritto:
On 18 September 2014 22:27, Paolo Di Pietro [email protected]
wrote:
Colin,
your suggestion is surely correct. My point is that I’m trying to perform an
over complex task dealing with a lot of new technologies to integrate.
I need a kick to bypass this stop.
Work through the tutorial first. A couple of days spend doing that
will save you time in the long run.