Joel Slowik
2008-Mar-03 19:02 UTC
Really simple question - how do I call information from the
I know how to create controllers and models. However what I do not know is how to call information into the front end of the site - particularly I do not know how to even place the graphic design into the site. I imagine I use the views. Ok, so I do that. Do I do ruby script/generate controller index? I have seen tutorials where the index is defined within a controller so I am not 100% sure on this. To help us out, essentially I want one page that serves the entire site (the index page). Everything will be called within that - so I assume the index view would be key. I will also be adding code to have a SEO friendly URL for each page that is requested. - Thats another topic so whatever. So how do I go about having a producting index page that calls the data that I am using in the admin (scaffolded) pages? Another thing that is throwing me off is the public folder - how does that come into play with the controllers and views? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Brian Hogan
2008-Mar-03 19:10 UTC
Re: Really simple question - how do I call information from the
Layouts wrap your views. When you scaffolded, you should have gotten a layout file in the layouts folder. Rename that to application.html.erb and it will be the default template for all pages. Next, the public folder is for your index page. However, things in the public folder don''t invoke Rails, so you won''t get to share the layout you just made. typically, what we do is delete public/index.html. Then we make a new controller ruby script/generate controller public index This creates a public controller and an index view. It will use the application layout as long as you have one. Then, take a look at config/routes.rb to specifiy that the main URL is /public/index. map.root :controller => "public", :action=>"index" (something similar is already commented out.) For more about the public folder, see "Page caching". Does that help? On Mon, Mar 3, 2008 at 1:02 PM, Joel Slowik < rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > I know how to create controllers and models. However what I do not know > is how to call information into the front end of the site - particularly > I do not know how to even place the graphic design into the site. > > I imagine I use the views. Ok, so I do that. Do I do ruby > script/generate controller index? > I have seen tutorials where the index is defined within a controller so > I am not 100% sure on this. > > To help us out, essentially I want one page that serves the entire site > (the index page). Everything will be called within that - so I assume > the index view would be key. I will also be adding code to have a SEO > friendly URL for each page that is requested. - Thats another topic so > whatever. > > So how do I go about having a producting index page that calls the data > that I am using in the admin (scaffolded) pages? > > Another thing that is throwing me off is the public folder - how does > that come into play with the controllers and views? > -- > Posted via http://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Robby Balona
2008-Mar-03 19:32 UTC
Re: Really simple question - how do I call information from the
or use a redirect script in the public/index.html page> Layouts wrap your views. When you scaffolded, you should have gotten a > layout file in the layouts folder. Rename that to application.html.erb and > it will be the default template for all pages. > > Next, the public folder is for your index page. However, things in the > public folder don''t invoke Rails, so you won''t get to share the layout you > just made. > > typically, what we do is delete public/index.html. Then we make a new > controller > > ruby script/generate controller public index > > This creates a public controller and an index view. It will use the > application layout as long as you have one. > > Then, take a look at config/routes.rb to specifiy that the main URL is > /public/index. > > map.root :controller => "public", :action=>"index" > > (something similar is already commented out.) > > For more about the public folder, see "Page caching". Does that help? > > On Mon, Mar 3, 2008 at 1:02 PM, Joel Slowik < > rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: > >> >> I know how to create controllers and models. However what I do not know >> is how to call information into the front end of the site - particularly >> I do not know how to even place the graphic design into the site. >> >> I imagine I use the views. Ok, so I do that. Do I do ruby >> script/generate controller index? >> I have seen tutorials where the index is defined within a controller so >> I am not 100% sure on this. >> >> To help us out, essentially I want one page that serves the entire site >> (the index page). Everything will be called within that - so I assume >> the index view would be key. I will also be adding code to have a SEO >> friendly URL for each page that is requested. - Thats another topic so >> whatever. >> >> So how do I go about having a producting index page that calls the data >> that I am using in the admin (scaffolded) pages? >> >> Another thing that is throwing me off is the public folder - how does >> that come into play with the controllers and views? >> -- >> Posted via http://www.ruby-forum.com/. >> >> > >> > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Joel Slowik
2008-Mar-04 13:18 UTC
Re: Really simple question - how do I call information from the
Brian Hogan wrote:> Layouts wrap your views. When you scaffolded, you should have gotten a > layout file in the layouts folder. Rename that to application.html.erb > and > it will be the default template for all pages. > > Next, the public folder is for your index page. However, things in the > public folder don''t invoke Rails, so you won''t get to share the layout > you > just made. > > typically, what we do is delete public/index.html. Then we make a new > controller > > On Mon, Mar 3, 2008 at 1:02 PM, Joel Slowik <Ok I am with you so far. One question I have though is how to call multiple items into a single page - this might be a different topic all together? Say my index page is suppose to have its main content in the center, a username login / password option on the top, and cateogries on the top and the left. Each of the just mentioned have their own controllers and models since they are all their own tables in the db. So how do I include it all together? I was told in order to have the visual layout in my front end to put the layout in the layouts folder for say the index page (or the gloabl layout). Well thats peachy but I am not sure how to call all of the different models into one page using the <yield> Should I be thinking of this as having a layout for each controller then calling all of those seperate layouts into one? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Rob Biedenharn
2008-Mar-04 14:34 UTC
Re: Really simple question - how do I call information from the
On Mar 4, 2008, at 8:18 AM, Joel Slowik wrote:> Brian Hogan wrote: >> Layouts wrap your views. When you scaffolded, you should have >> gotten a >> layout file in the layouts folder. Rename that to >> application.html.erb >> and >> it will be the default template for all pages. >> >> Next, the public folder is for your index page. However, things in >> the >> public folder don''t invoke Rails, so you won''t get to share the >> layout >> you >> just made. >> >> typically, what we do is delete public/index.html. Then we make a >> new >> controller >> >> On Mon, Mar 3, 2008 at 1:02 PM, Joel Slowik < > > Ok I am with you so far. One question I have though is how to call > multiple items into a single page - this might be a different topic > all > together? > > Say my index page is suppose to have its main content in the center, a > username login / password option on the top, and cateogries on the top > and the left. Each of the just mentioned have their own controllers > and > models since they are all their own tables in the db.(I''m jumping into the middle of this thread so apologies if I''m repeating something already said.) Your implicit assumption that each table must be handled by its own controller is false. The login option can be a partial that is conditionally rendered (assuming the conventions of acts_as_authenticated): <% if logged_in? -%> <p><%= current_user.name %></p> <% else -%> <%= render :partial => ''login'' %> <% end -%> For the categories, the controller sets up an instance variable by invoking the model: @top_categories = Category.for_top @side_categories= Category.for_side(:kind => ''interesting'') which the layout or the view can render as a partial <%= render :partial => ''top_categories'', :object => @top_categories %> <%= render :partial => ''side_category'', :collection => @side_categories %> If these partials are used by more than one controller, you can place them all into an app/views/shared/ directory or refer to them with their native controller''s name: <%= render :partial => ''account/login'' %>> So how do I include it all together? I was told in order to have the > visual layout in my front end to put the layout in the layouts folder > for say the index page (or the gloabl layout). Well thats peachy but I > am not sure how to call all of the different models into one page > using > the <yield>In the layout: <%= yield :this_thing %> In your view: <% content_for :this_thing do %> <p>stuff</p> <%= link_to ''wow'', wow_path, :class => ''amazing'' %> <% end %> The view is actually rendered first and then the layout is found and wrapped around it even though you tend to think of it the other way around.> Should I be thinking of this as having a layout for each controller > then > calling all of those seperate layouts into one?You certainly can have a different layout per controller (which is the default actually if you follow the naming conventions), but you can also specify a layout directly: render :layout => ''alternate'' render :action => ''edit'', :layout => ''admin'' -Rob Rob Biedenharn http://agileconsultingllc.com Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Joel Slowik
2008-Mar-06 13:32 UTC
Re: Really simple question - how do I call information from the
Rob Biedenharn wrote:> > Your implicit assumption that each table must be handled by its own > controller is false.... >Ok actually imagine i quoted the entire thread you wrote - I thought it was too long to quote here. Let me just run my mind on this and confirm with me that my assumptions based on what you all said is correct. So I can (and will have to for my needs) remove index.html from the public folder. Instead I will generate a public index. I am assuming here that the keyword public within that command will create the index in the public directory? This is actually a problem I am considering. Essentially the entire site will be using one graphic template that is being created. If I am understanding this correctly, I will be placing the graphic design pieces into the layout. The visual aspect is going to be pretty much all stylesheet driven and html tables to place the css design accordingly. So I can simply put the <% yield :something %> where approriate within the html tables. Am I going the right direction here so far? That leads to my next question, what about stylesheets? can they be used within layouts? As far as everything else goes it seems pretty straight forward at the moment. I cannot wrap my head around act_as_authenticated but I need to worry about the above first. Thanks for all of your help so far -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Joel Slowik
2008-Mar-07 00:28 UTC
Re: Really simple question - how do I call information from
Actually, I just found out that even when you change the route so that I had my index page become a public controller I was still able to use the style sheets and images from the public directory. Could anyone enlighten me as to why it is happening this way? I would have thought that be routing to a different location would pretty much void any use of the public directory. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Mar 6, 2008, at 4:28 PM, Joel Slowik wrote:> > Actually, I just found out that even when you change the route so > that I > had my index page become a public controller I was still able to use > the > style sheets and images from the public directory. > > Could anyone enlighten me as to why it is happening this way? I would > have thought that be routing to a different location would pretty much > void any use of the public directory. > --What looks like yourdomain.com/ to the browser looks like /some/path/ to/your/app/public on your server. Put differently, /public is like your DocumentRoot. All your static files are served out of that document root, including images, javascripts and stylesheets (well, you can serve some or all of them dynamically, but that''s a different story for a different time). What routing affects is how requests that cannot be fulfilled by serving a static page are parsed. So, say the browser does a GET for yourdomain.com/ how does that work? First, the server (Apache or mongrel, maybe) looks for a default file in public. The default names commonly include "index.html" so if there''s an "index.html" there in the root of your public folder, it is served and story told. If there is no static file found, then the dispatcher is invoked to chase through the routes looking for something that could fulfill the request. In this case, it would be a fallback route if you''ve specified it. So, when you changed your fallback route to point to a dynamically generated page, that doesn''t mean that the GET requests for yourdomain.com/prototype.js and yourdomain.com/scaffold.css or whatever aren''t still served statically. That''s the behavior you want: Serve statically, if possible. Generate pages dynamically when necessary. HTH --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---