Ruby on Rails
Thursday, September 18, 2014
1) the route excepts to get 1-3 parts, separated by / and you are trying to get 4 things to match
-- 2) the real issue, try So you had missing ')' and probably next thing it would complain is that variables/methods factory/demo/user are not found...
On Thursday, September 18, 2014 11:01:45 PM UTC+2, Colin Law wrote:
<%= link_to "some text", "factory/demo/user/9" %>On Thursday, September 18, 2014 11:01:45 PM UTC+2, Colin Law wrote:
On 18 September 2014 21:52, Paolo Di Pietro <paolodi...@gmail.com> wrote:The direction seems to be right, so I created
1) the route
get ':part1/(:part2/(:part3))' =>'factory#demo'
2) the factory controller
Then I add the following line to my .erb
<%= link_to "some text", factory/demo/user/9 ) %>The error message says there is an unexpected ')' Perhaps that means there is a ')' that is unexpected.
Colin
but it returns the following error:
Completed 500 Internal Server Error in 45ms
SyntaxError (/home/pdipietro/gsn/app/views/identity_providers/ index.html.erb:33: syntax error, unexpected ')', expecting keyword_end
... text", factory/demo/user/9 ) );@output_buffer.safe_append='
...^):
app/views/identity_providers/index.html.erb:33: syntax error, unexpected ')', expecting keyword_end
Any further suggestion?
Paolo
Il giorno giovedì 18 settembre 2014 22:28:53 UTC+2, Jarmo Isotalo ha scritto:Im not sure if I get what exactly you are trying to accomplish, but:with routeget ':part1/(:part2/(:part3))' =>'demo#demo'And controllerclass DemoController < ApplicationController
def demo
render plain: params.inspect
end
endAnd thus /foo, /foo/bar and /foo/bar/baz will use DemoController#demo and :part1 :part2 and :part3 can be accessed from params hash# And just a snippet from http://guides.rubyonrails.org/routing.html#bound- parameters 3.1 Bound Parameters
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:
:controllermaps to the name of a controller in your application, and:actionmaps 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/1is processed by this route (because it hasn't matched any previous route in the file), then the result will be to invoke theshowaction of thePhotosController, and to make the final parameter"1"available asparams[:id]. This route will also route the incoming request of/photostoPhotosController, since#index :actionand:idare optional parameters, denoted by parentheses.
On Thursday, September 18, 2014 10:02:27 PM UTC+2, Paolo Di Pietro wrote:No, I still cannot do it.
I cannot use Hobo because I'm using Neo4j NoSql db, which doesn't run with Hobo.
I just would like to set up an abstract route redirecting everything to my AbstractController!
Il giorno martedì 16 settembre 2014 10:37:11 UTC+2, Jarmo Isotalo ha scritto:Cant you do it already?
On Monday, September 15, 2014 6:34:46 PM UTC+2, Paolo Di Pietro wrote:Hi all,
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.
Any suggestion is appreciated.
PaoloTo view this discussion on the web visit https://groups.google.com/d/--
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 .msgid/rubyonrails-talk/ .9d2c785c-64ec-433b-9bc9- f3906372cc8a%40googlegroups. com
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-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/3f5f8cb7-f299-4ed1-9bcb-29d117d249bd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment