Rails - Creating a Landing Page, which is different than the Web App - ruby-on-rails

I'm rails I've been building a web app.
But the web app is completely different than what the landing page (sign in, register, about, etc should look like)
How do rails developers handle this? Different layouts? Different CSS files? etc..
what's cleanest? Thanks

You could create a HomePage controller (with associated views), and write the index action for that.
If the layout for the home page is going to be different from the application's again, then in the app/views/layouts/ folder, create a home_page.html.erb template. This will automatically be used by a HomePageController instead of the default application.html.erb template.

Related

ruby on rails, adding a partial to each html page in the system

I'm currently working on a project which has ROR in backend, I need to add a noscript tag to every page in the system to show a banner to the user.
Does ROR provide an easy way to add a piece of html to every page?
Add it to the application layout file /app/views/layouts/application.html.erb. That file gets loaded for every view unless you have disabled this layout or have used a different layout.
If you have multiple layouts then place the <noscript>...</noscript> in a partial and render the partial in all the layouts.

Piranha CMS existing models and Piranha Menu

I cannot seem to figure out how to add my preexisting pages to the auto navigation menu that Piranha generates when I call #UI.Menu().
Currently, I am using the method described here under Getting the Models to pull CMS content and display it above my model data. I can successfully render the page with Piranha content, but I'm not sure how I can have this page display in the top navigation.
Alternatively, I can pull my data and display the CMS content by creating a new page type, but this means the page type is only ever used to display this single page. It shows up in the navigation generated by #UI.Menu(), but if I continue using this method, I would need to create an additional piranha controller for every Action.
My main objective is adding CMS functionality to my custom MVC project and have everything display in an automatically generated navigation with #UI.Menu().
If you want to add pages in the menu that aren't really controlled by the CMS add a single page type for them, for example "Application Page". Then check the documentation for page types under section 2.5 here http://piranhacms.org/docs/pages/page-types.
If you check the checkbox to allow pages to change the route you can specify the route on each page of this page type. This means you can add your application pages into the structure and the add the route to your controller/action.

Organizing the view directory in ruby on rails 3

I have a pages controller and my pages view directory.
Say I have a settings page that when visited displays a few links e.g. privacy, notifications, etc.
When each link is click the content of the pages for those links are loaded within the same page.
Now in my pages view directory I want to organize things slightly.
So instead of having the pages directory and all the view templates in that directory. I would like to have "pages" then "settings" then in the settings directory I would like to place my views files "privacy.html.erb", "notifications.html.erb" etc.
How can I do this and still have rails 3 know what view file to load?
Just using good old render:
render 'pages/settings/privacy'
to load privacy.html.erb.

problem with panel in ui layout

I am using a simple layout demo in my rails3 application
simple layout demo
in this demo there are 5 panel north,south,east,west,center
when I load my project this all panel show in each and every page.
instead of I want to some specific panel in different different page
give some idea how can i do that
Is the code from the simple layout demo all in your /app/views/layouts/application.html.rb? If so, rails will render everything from that file in every view. Since the jQuery code that does all of the stuff in that demo is in that same file, there may be no easy way to make that work with rails. The only thing I could think to do would be to have different .js files for different pages. each of these separate files would have jQuery code that creates the layout for that page, and is linked to that page using content_for and javascript_include_tag. I'm writing an app that uses jQuery UI and this is how I've had to do it. I created sub folders in my /public/javascripts directory that I named after my models to make it easier to keep all the .js files sorted.

Ruby on Rails ajax - dynamically loading all pages

I have a flash media player (similar to lala.com) that needs to continue to stream while people click around. I don't want to use an iframe.
So, I need to dynamically load all site pages with ajax no matter what link people click on.
I've got this working with Rails and JQuery for a single page. With this method I have to place a file.js.erb file for whatever controller is called. Example: example.com/home is called and I have to have an index.js.erb in the views home dir to respond to this.
I used:
http://railscasts.com/episodes/174-pagination-with-ajax
to get this to work on one page, but it wouldn't be DRY at all to copy .js.erb files to every controller.
Is there something I can do with the main application_controller or even with routes.rb?
I found a way to do this. You can load whatever pages you want via the jquery load method.
$('#result').load('ajax/test.html #container');
They will then be placed in the div with the #result id.
You can also specify a page fragment with #container so you only load the part you want.
This allows all your controllers to stay in tact etc with no extra js.
This is really going to impact your visibility to search engines. I also think it will mean you need to think about the flow of your controllers. Rather than having controllers responding with views that represent a page, controllers will respond with snippets of HTML/JSON/etc that get injected into the home page. Your home page acts as a coordinator, loading the content in and out. Perfectly fine to have js.erb files in each view folder ... as they should be returning content specific to an individual controller.

Resources