Pardon the newbism I've inhereted this bit of code and it is being
used in a couple of rhtml files. I'd like to avoid duplicate code by
pulling this out somehow - how would you do this? This is an ecommerce
app and the code is for the credit card expiration date fields.
Pardon the newbism I've inhereted this bit of code and it is being
used in a couple of rhtml files. I'd like to avoid duplicate code by
pulling this out somehow - how would you do this? This is an ecommerce
app and the code is for the credit card expiration date fields.
You could extract it into a partial you share accross the app.
Now, I have a partial _foo living under app/views/user and I am trying
to call it from inside bar.rhtml which lives under app/views/purchase
I am getting "Couldn't find template file for purchase/_foo" error
How to get around this?
Specify the path to the template, ie render :partial => 'user/
foo' (might need a leading / there, can't remember). I sometimes put
shared partials in a folder called something like shared, so that it
doesn't look like they belong more to one thing than another.
I sometimes put
shared partials in a folder called something like shared, so that it
doesn't look like they belong more to one thing than another.
Fred
In my "persnickety-ness", I take that approach one step further by have
an entire directory structure for partials that mirrors the views folder
(and sometimes includes further division). So if I have
app/views
-- order
-- person
-- product
I'll also have
app/views/partials
-- order
-- person
-- product
It might sound like a lot to manage, but since I tend to have a boat
load of partials, it is very well organized and incredibly easy to share
across different resources where they might be needed.
In my "persnickety-ness", I take that approach one step further by have
an entire directory structure for partials that mirrors the views folder
(and sometimes includes further division). So if I have
app/views
-- order
-- person
-- product
I'll also have
app/views/partials
-- order
-- person
-- product
Do you use the same approach when you have nested resources??
It might sound like a lot to manage, but since I tend to have a boat
load of partials, it is very well organized and incredibly easy to share
across different resources where they might be needed.
Do you put ALL partials in there? or only the shared?
Ya I prefer making a shared or a partials folder i my views where in
I would keep the partials which I use very often ,we can also create a
folder as a nested folder depending upon the purpose.