Closed olegantonyan closed 8 years ago
Hi!
There is a router
method available in every component. And router.params
is a hash that contains your id.
Here is example:
in Device::Show
component
module Devices
class Show
include Inesita::Component
def render
component Devices::Device, props: router.params[:id] # router.params is hash
end
end
end
Thanks! This is exactly what I need
btw, I think it would be nice if we could pass params to url_for
, more like link_to in rails. So, ugly router.url_for(Devices::Show).gsub(':id', 100500)
will become router.url_for(Devices::Show, id: 100500)
. Or I also missed this?
You're right, router.url_for
should take an optional params. I need to fix this. Thanks. Also current_url?
will not work if there is an param within.
Fixed in master.
0.3.1 released, you can update and use url_for with options hash :+1:
Very cool! Thank!
Hi I'm playing with Inesita and have a trouble. I want to create a link to a component which accepts an
id
parameter (or whatever another parameter). Like this:Device::Show
componentWhere
Devices::Device
is like a rails partialAnd
Device::Index
looks like thisHow can extract url parameter in a component? Or there is another approach instead of REST-like for frontend app made of components?
Thanks