RailsCasts Pro episodes are now free!
Learn more or hide this
Just wondering about last section, what if I wanted to use a layout for each subdomain this way? where to put layouts files?
@Amr: you'd need to create a directory under 'views' for each of the subdomains.. (note that you can decide yourself how to structure your custom view_path, this way you can reflect whatever directory structure you like..)
Hi Ryan, many thanks for the screencast !
I ask you a little clarification: in template inheritance if I put a new link into the application/_side.html.erb partial I'll view it into all children views because they are "extended" but in the episode the view is simple ovverridden (copied and modified), am I right ?
So, is it a "template inheritance" or a "template override" ?
It's "template override", but the controller inherits the template from the parent controller
Kudos! Great screen cast as usual. At 8:20, it should be "over-rode" not "over-rid" :o). Thanks and cheers!
This is awesome!
this + inherited_resources + (simple_form || formtastic) = scaffolding--
As a newbie to Rails this is very exciting, but I am wondering if there is a way to dry this up a little.
With the example, if you copy and override the side partial four times, in four different locations, then that is four places you will need to edit if you make changes to any of the links...
Or is this not a real world practical issue?
I think at that point I would use a combination of techniques - The inherited files could also include a partial of the common elements, and a partial of the added elements - that way you could override only the added elements.
That's really useful thanks
I'm trying to do something similar to the subdomain trick you just showed, but I want to change the controller that's used rather than the view. Is this possible?
I'm making a CMS where a user can create a site and enter their own subdomain. I'd like "/" to point to "public#welcome" if there's no subdomain, but if there is a subdomain, I want it to point to "sites/public#welcome".
root to: "public#welcome"
constraints subdomain: /.+/ do
root to: "sites/public#welcome"
Yeah, I'm doing that right now, but it seems like it will become tedious when I have a lot of controllers. Also, how would I define a resource, say "Post", where the controller is at controllers/sites/posts_controller.rb ?
I think I may have found my answer here actually:
...about to try it out now.
I figured it out:
constraints subdomain: /.+/ do
scope :module => "sites" do
root :to => 'public#welcome'
root :to => 'public#welcome'
great screencast as usual.
here is my question.
is it possible to give every viewpath custom assets? say i want to create different themes for every shop or every blog in my application. every theme would have different assets (js, css, images) and different layouts and would inherit default behaviour from /views and /public. currently i am using themes_for_rails gem which provides this feature, but a build in solution in rails 3.1 would be great.
Is it possible through template inheritance to make dynamic navigation...
Say that I had a blog application with a list of categories and wanted to link to those categories to show list of articles within those categories, could I use a dynamic method to create the links to the categories show page and place that in an inherited template?
Why did admin namespace not inherit from ApplicationController which inherits from BaseController ? Is the inheritance it limited to a namespace ?
prepend_view_path is awesome, I wish I had that on a big messy app I picked up some months ago, - thank you
How set the domain name in my application instead of localhost:3000.I'm using ubuntu os.plz tell any gem to set the domain name in my app.
Since prepend_view_path seems to be depreciated in rails 3.2, im looking for the "right" way todo it in 3.2.. any thoughts anyone?
It looks like the deprecation was an empty threat because it's there in 3.2:
<%= controller.view_paths %> dont work. It shows me: #ActionView::PathSet:0x007fe6952365a8
What should I do?
They changed the string array to a PathSet class in Rails 3.2.
To see it as a string array, <%= controller.view_paths.map &:to_path %>
Your blog is extremely good, excellent operate... www.yeezy350find.com
How to Care for Coach Leather Handbags www.mkpee.com
Coach leather handbags are very desirable and fashionable. Coach is known for its high-quality goods and its styles have passed the test of time. www.mkuker.com Women proudly carry their Coach leather handbags for many years. They are, however, a major investment. www.mkzho.com Once you have purchased one, you will want to keep it in excellent www.nikeyeah.com condition to protect that investment. www.mkpee.com Be aware of where you are putting your bag; try not to place it on the floor. A purse hook is a handy little item to carry in your purse that lets you www.nikeshoesales.com hook your purse to a tabletop or other flat surface.
Lightly www.lightupshoe.sale clean your purse once a month, or more often if you carry it in a dirty environment. You can use a baby wipe to lightly wipe the surface. There are also leather wipes available. You do not want to get your Coach leather handbag wet so do not use a wet cloth to clean it. Use Coach-brand fabric cleaner if your bag is a signature Coach bag made of fabric. The fabric cleaner should only be used on fabric bags. www.nikemax.shoes Use a high-quality leather cleaner for heavier cleaning. www.shoesmaxs.com
After cleaning your handbag, apply a high-quality leather moisturizer to help keep it conditioned.To clean the inside of your bag, use the hose attachment on your vacuum and gently clean the inside.After cleaning, always store your handbag in the www.mkfact.com dust bag that came with it or a cotton pillow case. Lay it flat on a shelf and do not stack or crush your Coach leather handbags.
First sign in through GitHub to post a comment.