Hi everyone, I need several pages to be static but also modify when requested. I try following the railcast from Ryan at http://railscasts.com/episodes/117-semi-static-pages?view=comments Here what I have done!! rails g scaffold Pages name:string permanentlink:string title:string author:string access_level:string is_published:boolean meta_description:string meta_keyword:string meta_author:string content:text route.db get ''static/:permanentlink'', :controller => ''pages'', :action =>''show'' show.html.erb <p id="notice"><%= notice %></p> <p> <%= @page.title %> </p> <p> <%= @page.content %> </p> <%= link_to ''Edit'', edit_page_path(@page) %> | <%= link_to ''Back'', pages_path %> controller#show.rb def show if params[:permanentlink] @page = Page.find_by_permanentlink(params[:permanentlink]) else @page = Page.find(params[:id]) end respond_to do |format| format.html # show.html.erb format.json { render json: @page } end end The error NoMethodError in Pages#show Showing /home/jean/rail/wyw/app/views/pages/show.html.erb where line #3 raised: undefined method `title'' for nil:NilClass Extracted source (around line #3): 1: <p id="notice"><%= notice %></p> 2: <p> 3: <%= @page.title %> 4: </p> 5: 6: <p> Rails.root: /home/jean/rail/wyw Application Trace | Framework Trace | Full Trace app/views/pages/show.html.erb:3:in `_app_views_pages_show_html_erb___833700274_82427120'' app/controllers/pages_controller.rb:21:in `show'' Is this even a technique that his been used these day or is it to old, if still use what do i do wrong? -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
On 17 July 2012 15:42, Jean-Sébastien D. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hi everyone, > > I need several pages to be static but also modify when requested. I try > following the railcast from Ryan at > http://railscasts.com/episodes/117-semi-static-pages?view=comments > > Here what I have done!! > > rails g scaffold Pages name:string permanentlink:string title:string > author:string access_level:string is_published:boolean > meta_description:string meta_keyword:string meta_author:string > content:text > > route.db > get ''static/:permanentlink'', :controller => ''pages'', :action =>''show'' > > > show.html.erb > <p id="notice"><%= notice %></p> > <p> > <%= @page.title %> > </p> > > <p> > <%= @page.content %> > </p> > <%= link_to ''Edit'', edit_page_path(@page) %> | > <%= link_to ''Back'', pages_path %> > > controller#show.rb > def show > if params[:permanentlink] > @page = Page.find_by_permanentlink(params[:permanentlink]) > else > @page = Page.find(params[:id]) > end > respond_to do |format| > format.html # show.html.erb > format.json { render json: @page } > end > end > > > The error > NoMethodError in Pages#show > > Showing /home/jean/rail/wyw/app/views/pages/show.html.erb where line #3 > raised: > > undefined method `title'' for nil:NilClass > Extracted source (around line #3): > > 1: <p id="notice"><%= notice %></p> > 2: <p> > 3: <%= @page.title %>The error means that @page is nil, so your find is not finding anything. Have a look at the Rails Guide on debugging for ideas on how to debug your code. Colin> 4: </p> > 5: > 6: <p> > Rails.root: /home/jean/rail/wyw > > Application Trace | Framework Trace | Full Trace > app/views/pages/show.html.erb:3:in > `_app_views_pages_show_html_erb___833700274_82427120'' > app/controllers/pages_controller.rb:21:in `show'' > > Is this even a technique that his been used these day or is it to old, > if still use what do i do wrong? > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Hi everyone, I followed the railcast from Ryan at http://railscasts.com/episodes/117-semi-static-pages and works. But what I would like to do is on my general layouts have the permalink to be generated this is where i get confused with the tutorial ruby on rails http://ruby.railstutorial.org/chapters/ My scaffold is called pages. I though we could fetch the resource by doing has follow <%= render @pages %> But i am getting and error ArgumentError in Static_pages#home Showing /home/jean/rail/wyw/app/views/layouts/_footer.html.erb where line #6 raised: ''nil'' is not an ActiveModel-compatible object that returns a valid partial path. Extracted source (around line #6): 3: Copyright Where you Where 2012 4: </small> 5: 6: <%= render @pages %> 7: <nav> 8: <ul> 9: <li><%= link_to "About", ''#'' %></li> Trace of template inclusion: app/views/layouts/application.html.erb Rails.root: /home/jean/rail/wyw Application Trace | Framework Trace | Full Trace Then the tutorial say i have to add a _page.html.erb which i added into the folder of pages, but render@pages doesnt see it. Not sure what to do!! Thanks -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
On 17 July 2012 16:09, Jean-Sébastien D. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hi everyone, > > I followed the railcast from Ryan at > http://railscasts.com/episodes/117-semi-static-pages and works. But what > I would like to do is on my general layouts have the permalink to be > generated this is where i get confused with the tutorial ruby on rails > http://ruby.railstutorial.org/chapters/ > > My scaffold is called pages. I though we could fetch the resource by > doing has follow > > <%= render @pages %> > But i am getting and error > > ArgumentError in Static_pages#home > > Showing /home/jean/rail/wyw/app/views/layouts/_footer.html.erb where > line #6 raised: > > ''nil'' is not an ActiveModel-compatible object that returns a valid > partial path. > Extracted source (around line #6): > > 3: Copyright Where you Where 2012 > 4: </small> > 5: > 6: <%= render @pages %>Same again, @pages is nil. Try to look at the error and see if you can understand what it means. Colin> 7: <nav> > 8: <ul> > 9: <li><%= link_to "About", ''#'' %></li> > Trace of template inclusion: app/views/layouts/application.html.erb > > Rails.root: /home/jean/rail/wyw > > Application Trace | Framework Trace | Full Trace > > Then the tutorial say i have to add a _page.html.erb which i added into > the folder of pages, but render@pages doesnt see it. Not sure what to > do!! > > Thanks > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Colin Law wrote in post #1069081:> On 17 July 2012 16:09, Jean-Sbastien D. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> >> Extracted source (around line #6): >> >> 3: Copyright Where you Where 2012 >> 4: </small> >> 5: >> 6: <%= render @pages %> > > Same again, @pages is nil. Try to look at the error and see if you > can understand what it means. > > ColinWell now what I have done his has follow <%= render @page.name %> And get the error has follow: The partial name (About Us) is not a valid Ruby identifier; make sure your partial name starts with a letter or underscore, and is followed by any combinations of letters, numbers, or underscores. So to me this should be the string About Us and placing has html. Did i miss something??? I do know that the page.name = "About Us" But why not just displaying it has a html string. What step did i confused. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
On 17 July 2012 17:03, Jean-Sébastien D. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Colin Law wrote in post #1069081: >> On 17 July 2012 16:09, Jean-Sbastien D. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >>> >>> Extracted source (around line #6): >>> >>> 3: Copyright Where you Where 2012 >>> 4: </small> >>> 5: >>> 6: <%= render @pages %> >> >> Same again, @pages is nil. Try to look at the error and see if you >> can understand what it means. >> >> Colin > > Well now what I have done his has follow > > <%= render @page.name %> > > And get the error has follow: > The partial name (About Us) is not a valid Ruby identifier; make sure > your partial name starts with a letter or underscore, and is followed by > any combinations of letters, numbers, or underscores. > > So to me this should be the string About Us and placing has html. Did i > miss something??? I do know that the page.name = "About Us" But why not > just displaying it has a html string. What step did i confused.Have a look at the Rails Guide on Layouts and Rendering. Section 2 describes how to use render, but read and understand the rest of it. I forget whether you are a beginner. If so then work right through some tutorials such as railstutorial.org to understand the basics of Rails, also look at the other Rails Guides. Colin -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
On 17 July 2012 17:10, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 17 July 2012 17:03, Jean-Sébastien D. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> Colin Law wrote in post #1069081: >>> On 17 July 2012 16:09, Jean-Sbastien D. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >>>> >>>> Extracted source (around line #6): >>>> >>>> 3: Copyright Where you Where 2012 >>>> 4: </small> >>>> 5: >>>> 6: <%= render @pages %> >>> >>> Same again, @pages is nil. Try to look at the error and see if you >>> can understand what it means. >>> >>> Colin >> >> Well now what I have done his has follow >> >> <%= render @page.name %> >> >> And get the error has follow: >> The partial name (About Us) is not a valid Ruby identifier; make sure >> your partial name starts with a letter or underscore, and is followed by >> any combinations of letters, numbers, or underscores. >> >> So to me this should be the string About Us and placing has html. Did i >> miss something??? I do know that the page.name = "About Us" But why not >> just displaying it has a html string. What step did i confused. > > Have a look at the Rails Guide on Layouts and Rendering. Section 2 > describes how to use render, but read and understand the rest of it. > > I forget whether you are a beginner. If so then work right through > some tutorials such as railstutorial.org to understand the basics of > Rails, also look at the other Rails Guides.Looking back I see that I have already advised that. How are you getting on with the tutorials. Colin> > Colin-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Colin Law wrote in post #1069088:> On 17 July 2012 17:10, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: >>>> > > ColinYes I am new to Ruby on Rails. I have read and try several tutorial in the last 2 weeks. But this is what I am trying to do. I have a create a file Static_Pages/homes which his just a static pages. It has the following structure <!DOCTYPE html> <html> <head> <title><%= full_title(yield(:title)) %></title> <%= content_for(full_meta_description(yield(:meta_description))).html_safe %> <%= full_meta_keyword(yield(:meta_keyword)) %> <%= full_meta_author(yield(:meta_author)) %> <%= stylesheet_link_tag "application", media: "all" %> <%= javascript_include_tag "application" %> <%= render ''layouts/shim'' %> </head> <body> <%= render ''layouts/header'' %> <div class="container"> <%= yield %> </div> <%= render ''layouts/footer'' %> </body> </html> _footer.html would then have page links to my resources pages which contains static links such About Us, Company News, etc... Based on this tutorial http://ruby.railstutorial.org/chapters/user-microposts#sec:manipulating_microposts section 10.22 you must use render to allow to insert a file which you then create which can be use if there is an association. However there is no association, About Us and Company News aren''t related to a user or somesort. Any solution that ruby can have if i dont have a model association between those two field? -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
On 17 July 2012 17:50, Jean-Sébastien D. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Colin Law wrote in post #1069088: >> On 17 July 2012 17:10, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: >>>>> >> >> Colin > > Yes I am new to Ruby on Rails. I have read and try several tutorial in > the last 2 weeks.Reading several tutorials is not sufficient. Work right through railstutorial.org, entering the code, running it, and doing the exercises. Make sure you understand absolutely every line of code. Colin> But this is what I am trying to do. > > I have a create a file Static_Pages/homes which his just a static pages. > > It has the following structure > > <!DOCTYPE html> > <html> > <head> > <title><%= full_title(yield(:title)) %></title> > <%> content_for(full_meta_description(yield(:meta_description))).html_safe > %> > <%= full_meta_keyword(yield(:meta_keyword)) %> > <%= full_meta_author(yield(:meta_author)) %> > > <%= stylesheet_link_tag "application", media: "all" %> > <%= javascript_include_tag "application" %> > <%= render ''layouts/shim'' %> > </head> > <body> > <%= render ''layouts/header'' %> > <div class="container"> > <%= yield %> > </div> > <%= render ''layouts/footer'' %> > </body> > </html> > > _footer.html would then have page links to my resources pages which > contains static links such About Us, Company News, etc... Based on this > tutorial > http://ruby.railstutorial.org/chapters/user-microposts#sec:manipulating_microposts > section 10.22 you must use render to allow to insert a file which you > then create which can be use if there is an association. However there > is no association, About Us and Company News aren''t related to a user or > somesort. > > Any solution that ruby can have if i dont have a model association > between those two field? > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Colin Law wrote in post #1069096:> On 17 July 2012 17:50, Jean-Sbastien D. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: > > Reading several tutorials is not sufficient. Work right through > railstutorial.org, entering the code, running it, and doing the > exercises. Make sure you understand absolutely every line of code. > > ColinThat my problem, I don''t understand! I have try to make the tutorial but i don''t get it. Using example 10.22 it says to insert a micropost into a user field you must do has follow <%= render @resources %> into the location where you want the micropost to appear or the content You then create a file called _micropost.html.erb in the folder micropost/_micropost.html.erb And voila, to me this is how i see it, I do see that you might have to define in the controller users @micropost.user to allow the association to works. But in my program this particular model doesn''t have an association. Is there something I miss, does Rails allow a way to go around this or no. Cause if no, then I must change language -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
On 17 July 2012 18:04, Jean-Sébastien D. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Colin Law wrote in post #1069096: >> On 17 July 2012 17:50, Jean-Sbastien D. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> >> Reading several tutorials is not sufficient. Work right through >> railstutorial.org, entering the code, running it, and doing the >> exercises. Make sure you understand absolutely every line of code. >> >> Colin > > That my problem, I don''t understand! I have try to make the tutorial but > i don''t get it. Using example 10.22 it says to insert a micropost into a > user field you must do has follow > > <%= render @resources %> into the location where you want the micropost > to appear or the contentI can''t find that in the tutorial. Which section and listing number is it in. Colin> > You then create a file called _micropost.html.erb in the folder > micropost/_micropost.html.erb > > And voila, to me this is how i see it, I do see that you might have to > define in the controller users @micropost.user to allow the association > to works. But in my program this particular model doesn''t have an > association. Is there something I miss, does Rails allow a way to go > around this or no. Cause if no, then I must change language > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Colin Law wrote in post #1069113:> On 17 July 2012 18:04, Jean-Sbastien D. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> i don''t get it. Using example 10.22 it says to insert a micropost into a >> user field you must do has follow >> >> <%= render @resources %> into the location where you want the micropost >> to appear or the content > > I can''t find that in the tutorial. Which section and listing number is > it in. > > Colinits actually microposts i was refering resources to any resource or model that exists has broader concept. But it still his <%= render @microposts %> then you must create a file with all the information that you want to show in the folder microposts/_microposts.html.erb Once this is done then you need to tell in the User controllers def show @user = User.find(params[:id]) @microposts = @user.microposts.paginate(page: params[:page]) end But what if my model doesn''t have a relation between the two! Then i can''t use it? -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
On 17 July 2012 20:46, Jean-Sébastien D. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Colin Law wrote in post #1069113: >> On 17 July 2012 18:04, Jean-Sbastien D. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >>> i don''t get it. Using example 10.22 it says to insert a micropost into a >>> user field you must do has follow >>> >>> <%= render @resources %> into the location where you want the micropost >>> to appear or the content >> >> I can''t find that in the tutorial. Which section and listing number is >> it in. >> >> Colin > > its actually microposts i was refering resources to any resource or > model that exists has broader concept. > > But it still his <%= render @microposts %> then you must create a file > with all the information that you want to show in the folder > microposts/_microposts.html.erb > > Once this is done then you need to tell in the User controllers > > def show > @user = User.find(params[:id]) > @microposts = @user.microposts.paginate(page: params[:page]) > end > > But what if my model doesn''t have a relation between the two! Then i > can''t use it?Are you just trying to render a static partial? Colin -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Colin Law wrote in post #1069118:> On 17 July 2012 20:46, Jean-Sbastien D. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >>> >> >> def show >> @user = User.find(params[:id]) >> @microposts = @user.microposts.paginate(page: params[:page]) >> end >> >> But what if my model doesn''t have a relation between the two! Then i >> can''t use it? > > Are you just trying to render a static partial? > > ColinYes So my footer can have dynamic link to different page, presented by ryan in the railcast http://railscasts.com/episodes/117-semi-static-pages?autoplay=true -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
On 17 July 2012 20:53, Jean-Sébastien D. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Colin Law wrote in post #1069118: >> On 17 July 2012 20:46, Jean-Sbastien D. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >>>> >>> >>> def show >>> @user = User.find(params[:id]) >>> @microposts = @user.microposts.paginate(page: params[:page]) >>> end >>> >>> But what if my model doesn''t have a relation between the two! Then i >>> can''t use it? >> >> Are you just trying to render a static partial? >> >> Colin > > YesHow far through the tutorial have you worked? Colin> > > So my footer can have dynamic link to different page, presented by ryan > in the railcast > http://railscasts.com/episodes/117-semi-static-pages?autoplay=true > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Jean-Sébastien D.
2012-Jul-17 20:06 UTC
Re: Re: Re: Re: Re: Re: Static Pages from Railcast
Colin Law wrote in post #1069121:> On 17 July 2012 20:53, Jean-Sbastien D. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >>>> can''t use it? >>> >>> Are you just trying to render a static partial? >>> >>> Colin >> >> Yes > > How far through the tutorial have you worked? > > ColinWell the fartest i was was 9, but I retry today, i am going to scratch it again, I did skip to best fit my program. But it remainds the main issues is that I can''t simply render a resource into an other page. Is it at least possible? -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
On 17 July 2012 21:06, Jean-Sébastien D. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Colin Law wrote in post #1069121: >> On 17 July 2012 20:53, Jean-Sbastien D. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >>>>> can''t use it? >>>> >>>> Are you just trying to render a static partial? >>>> >>>> Colin >>> >>> Yes >> >> How far through the tutorial have you worked? >> >> Colin > > Well the fartest i was was 9, but I retry today, i am going to scratch > it again, I did skip to best fit my program. But it remainds the main > issues is that I can''t simply render a resource into an other page. Is > it at least possible?The reason I asked was that listing 10.30 shows how to render a fixed page. Also the other advise I gave to study the rails guide on rendering would do that. There really is no shortcut, you need to learn stuff. The best way to start is by carrying on through the tutorial and studying the rails guides. Colin -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Jean-Sébastien D.
2012-Jul-17 22:57 UTC
Re: Re: Re: Re: Re: Re: Re: Static Pages from Railcast
Colin Law wrote in post #1069130:> On 17 July 2012 21:06, Jean-Sbastien D. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >>> How far through the tutorial have you worked? >>> >>> Colin >> >> Well the fartest i was was 9, but I retry today, i am going to scratch >> it again, I did skip to best fit my program. But it remainds the main >> issues is that I can''t simply render a resource into an other page. Is >> it at least possible? > > The reason I asked was that listing 10.30 shows how to render a fixed > page. Also the other advise I gave to study the rails guide on > rendering would do that. There really is no shortcut, you need to > learn stuff. The best way to start is by carrying on through the > tutorial and studying the rails guides. > > ColinI understand well your telling me its possible which his good I however re did everything from the tutorial and on the test i am getting error Here the command bundle exec rspec spec/requests/static_pages_spec.rb The result F Failures: 1) Static pages Home page should have the content ''Sample App'' Failure/Error: visit ''/static_pages/home'' NoMethodError: undefined method `visit'' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_1:0xa1695cc> # ./spec/requests/static_pages_spec.rb:7:in `block (3 levels) in <top (required)>'' Finished in 0.04033 seconds 1 example, 1 failure Failed examples: rspec ./spec/requests/static_pages_spec.rb:6 # Static pages Home page should have the content ''Sample App'' Why would visit not be defined? Thanks for your help, not sure why its gives me this -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
Colin Law
2012-Jul-18 06:32 UTC
Re: Re: Re: Re: Re: Re: Re: Re: Static Pages from Railcast
On 17 July 2012 23:57, Jean-Sébastien D. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Colin Law wrote in post #1069130: >> On 17 July 2012 21:06, Jean-Sbastien D. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >>>> How far through the tutorial have you worked? >>>> >>>> Colin >>> >>> Well the fartest i was was 9, but I retry today, i am going to scratch >>> it again, I did skip to best fit my program. But it remainds the main >>> issues is that I can''t simply render a resource into an other page. Is >>> it at least possible? >> >> The reason I asked was that listing 10.30 shows how to render a fixed >> page. Also the other advise I gave to study the rails guide on >> rendering would do that. There really is no shortcut, you need to >> learn stuff. The best way to start is by carrying on through the >> tutorial and studying the rails guides. >> >> Colin > > I understand well your telling me its possible which his good > I however re did everything from the tutorial and on the test i am > getting error > > Here the command > bundle exec rspec spec/requests/static_pages_spec.rb > > The result > F > > Failures: > > 1) Static pages Home page should have the content ''Sample App'' > Failure/Error: visit ''/static_pages/home'' > NoMethodError: > undefined method `visit'' for > #<RSpec::Core::ExampleGroup::Nested_1::Nested_1:0xa1695cc> > # ./spec/requests/static_pages_spec.rb:7:in `block (3 levels) in > <top (required)>'' > > Finished in 0.04033 seconds > 1 example, 1 failure > > Failed examples: > > rspec ./spec/requests/static_pages_spec.rb:6 # Static pages Home page > should have the content ''Sample App'' > > Why would visit not be defined? Thanks for your help, not sure why its > gives me thisMy best guess would be that you have an error in the test code. If you cannot see it then post static_pages_spec.rb here. Copy/paste it from your actual code so we can check for typos. Colin> > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Jean-Sébastien D.
2012-Jul-18 13:13 UTC
Re: Re: Re: Re: Re: Re: Re: Re: Static Pages from Railcast
Colin Law wrote in post #1069168:> On 17 July 2012 23:57, Jean-Sbastien D. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >>> >> getting error >> Failure/Error: visit ''/static_pages/home'' >> >> rspec ./spec/requests/static_pages_spec.rb:6 # Static pages Home page >> should have the content ''Sample App'' >> >> Why would visit not be defined? Thanks for your help, not sure why its >> gives me this > > My best guess would be that you have an error in the test code. If > you cannot see it then post static_pages_spec.rb here. Copy/paste it > from your actual code so we can check for typos. > > ColinLol here what I have spec/requests/static_pages_spec.rb describe "Static pages" do describe "Home page" do it "should have the content ''Sample App''" do visit ''/static_pages/home'' page.should have_content(''Sample App'') end end end app/views/layouts/application.html.erb <!DOCTYPE html> <html> <head> <title><%= full_title(yield(:title)) %></title> <<%= full_meta_description(yield(:meta_description)) %> /> <<%= full_meta_keyword(yield(:meta_keyword)) %> /> <<%= full_meta_author(yield(:meta_author)) %> /> <%= stylesheet_link_tag "application", media: "all" %> <%= javascript_include_tag "application" %> <%= csrf_meta_tags %> <%= render ''layouts/shim'' %> </head> <body> <%= render ''layouts/header'' %> <div class="container"> <% flash.each do |key, value| %> <div class="alert alert-<%= key %>"><%= value %></div> <% end %> <%= yield %> <%= render ''layouts/footer'' %> <%= debug(params) if Rails.env.development? %> </div> </body> </html> app/views/static_pages/home.html.erb Sample App <div class="left_column"> </div> <div class="right_column"> <%= link_to "Sign Up", ''signup_path'' %> </div> And do as follow to run the test bundle exec rspec spec/requests/static_pages_spec.rb -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
Colin Law
2012-Jul-18 13:58 UTC
Re: Re: Re: Re: Re: Re: Re: Re: Re: Static Pages from Railcast
On 18 July 2012 14:13, Jean-Sébastien D. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Colin Law wrote in post #1069168: >> On 17 July 2012 23:57, Jean-Sbastien D. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >>>> >>> getting error >>> Failure/Error: visit ''/static_pages/home'' >>> >>> rspec ./spec/requests/static_pages_spec.rb:6 # Static pages Home page >>> should have the content ''Sample App'' >>> >>> Why would visit not be defined? Thanks for your help, not sure why its >>> gives me this >> >> My best guess would be that you have an error in the test code. If >> you cannot see it then post static_pages_spec.rb here. Copy/paste it >> from your actual code so we can check for typos. >> >> Colin > > Lol here what I have > > spec/requests/static_pages_spec.rb > describe "Static pages" do > > describe "Home page" do > it "should have the content ''Sample App''" do > visit ''/static_pages/home'' > page.should have_content(''Sample App'') > end > end > endThat is not quite the same as that in Listing 3.9 on http://ruby.railstutorial.org/chapters/static-pages#top You seem to have a bit missing at the beginning. Whether that is the cause of the problem I don''t know. Colin> > app/views/layouts/application.html.erb > <!DOCTYPE html> > <html> > <head> > <title><%= full_title(yield(:title)) %></title> > <<%= full_meta_description(yield(:meta_description)) %> /> > <<%= full_meta_keyword(yield(:meta_keyword)) %> /> > <<%= full_meta_author(yield(:meta_author)) %> /> > > <%= stylesheet_link_tag "application", media: "all" %> > <%= javascript_include_tag "application" %> > <%= csrf_meta_tags %> > <%= render ''layouts/shim'' %> > </head> > <body> > <%= render ''layouts/header'' %> > <div class="container"> > <% flash.each do |key, value| %> > <div class="alert alert-<%= key %>"><%= value %></div> > <% end %> > <%= yield %> > <%= render ''layouts/footer'' %> > <%= debug(params) if Rails.env.development? %> > </div> > </body> > </html> > > app/views/static_pages/home.html.erb > Sample App > <div class="left_column"> > </div> > <div class="right_column"> > <%= link_to "Sign Up", ''signup_path'' %> > </div> > > And do as follow to run the test > bundle exec rspec spec/requests/static_pages_spec.rb > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Other people have reported this error:>>> NoMethodError: >>> undefined method `visit'' for >>> #<RSpec::Core::ExampleGroup::Nested_1::Nested_1:0xa1695cc> >>> # ./spec/requests/static_pages_spec.rb:7:in `block (3 levels) in >>> <top (required)>''google: rspec visit In particular see: https://github.com/rspec/rspec-rails/issues/360 You might want to post your Gemfile. On Jul 17, 2012, at 11:32 PM, Colin Law wrote:> On 17 July 2012 23:57, Jean-Sébastien D. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> Colin Law wrote in post #1069130: >>> On 17 July 2012 21:06, Jean-Sbastien D. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >>>>> How far through the tutorial have you worked? >>>>> >>>>> Colin >>>> >>>> Well the fartest i was was 9, but I retry today, i am going to scratch >>>> it again, I did skip to best fit my program. But it remainds the main >>>> issues is that I can''t simply render a resource into an other page. Is >>>> it at least possible? >>> >>> The reason I asked was that listing 10.30 shows how to render a fixed >>> page. Also the other advise I gave to study the rails guide on >>> rendering would do that. There really is no shortcut, you need to >>> learn stuff. The best way to start is by carrying on through the >>> tutorial and studying the rails guides. >>> >>> Colin >> >> I understand well your telling me its possible which his good >> I however re did everything from the tutorial and on the test i am >> getting error >> >> Here the command >> bundle exec rspec spec/requests/static_pages_spec.rb >> >> The result >> F >> >> Failures: >> >> 1) Static pages Home page should have the content ''Sample App'' >> Failure/Error: visit ''/static_pages/home'' >> NoMethodError: >> undefined method `visit'' for >> #<RSpec::Core::ExampleGroup::Nested_1::Nested_1:0xa1695cc> >> # ./spec/requests/static_pages_spec.rb:7:in `block (3 levels) in >> <top (required)>'' >> >> Finished in 0.04033 seconds >> 1 example, 1 failure >> >> Failed examples: >> >> rspec ./spec/requests/static_pages_spec.rb:6 # Static pages Home page >> should have the content ''Sample App'' >> >> Why would visit not be defined? Thanks for your help, not sure why its >> gives me this > > My best guess would be that you have an error in the test code. If > you cannot see it then post static_pages_spec.rb here. Copy/paste it > from your actual code so we can check for typos. > > Colin > >> >> -- >> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit https://groups.google.com/groups/opt_out. >> >> > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Jean-Sébastien D.
2012-Jul-18 14:13 UTC
Re: Re: Re: Re: Re: Re: Re: Re: Static Pages from Railcast
Jim Oser wrote in post #1069201:> Other people have reported this error: > >>>> NoMethodError: >>>> undefined method `visit'' for >>>> #<RSpec::Core::ExampleGroup::Nested_1::Nested_1:0xa1695cc> >>>> # ./spec/requests/static_pages_spec.rb:7:in `block (3 levels) in >>>> <top (required)>'' > > google: rspec visit > > In particular see: > > https://github.com/rspec/rspec-rails/issues/360 > > You might want to post your Gemfile.Hmm i see my issues, i installed the rspec not through my gemfile but through a command line gem install rspec. Would this be the issue -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
What i am doing wrong?? So I am at chapter 8, and everything seem to be working except that once loggin I am apparently not login but do see some of the information such as show correct user. Here what I have app/controllers/customers.rb class CustomersController < ApplicationController def show @customer = Customer.find(params[:id]) end def create @customer = Customer.new(params[:customer]) if @customer.save sign_in @customer flash[:success] = "Welcome to Where you Where" redirect_to @customer # Handle a successful save. else render ''new'' end end def new @customer = Customer.new end def edit @customer = Customer.find(params[:id]) end def update if @customer.update_attributes(params[:customer]) flash[:success] = "Profile updated" sign_in @customer redirect_to @customer else render ''edit'' end end private def signed_in_customer redirect_to signin_path, notice: "Please sign in." unless signed_in? end def correct_customer @customer = Customer.find(params[:id]) redirect_to(root_path) unless current_customer?(@customer) end end I have change the name of the resource from user to customer for trying different then the person this is my session help found in the folder app/helpers/session.rb module SessionsHelper def sign_in(customer) cookies.permanent[:remember_token] = customer.remember_token self.current_customer= customer end def current_customer=(customer) @current_customer = customer end def current_customer?(customer) customer == current_customer end def current_customer @current_customer ||= Customer.find_by_remember_token(cookies[:remember_token]) end def sign_in(customer) cookies.permanent[:remember_token] = customer.remember_token self.current_customer = customer end def signed_in? !current_customer.nil? end def sign_out cookies.delete(:remember_token) self.current_customer = nil end end Here his my header just in case i made a small mistake <header class="navbar navbar-fixed-top"> <div class="navbar-inner"> <div class="container"> <nav> <ul class="nav pull-right"> <li><%= link_to "Home", root_path %></li> <% if signed_in? %> <li><%= link_to "Customers", ''#'' %></li> <li id="fat-menu" class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown"> Account <b class="caret"></b> </a> <ul class="dropdown-menu"> <li><%= link_to "Profile", current_customer %></li> <li><%= link_to "Settings", ''#'' %></li> <li class="divider"></li> <li> <%= link_to "Sign out", signout_path, method: "delete" %> </li> </ul> </li> <% else %> <li><%= link_to "Sign in", signin_path %></li> <% end %> </ul> </nav> </div> </div> </header> Again i only see sign and home as link has i am assuming something his wrong with my sign process -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
Jean-Sébastien D.
2012-Jul-18 17:34 UTC
Re: Re: Re: Re: Re: Re: Re: Re: Static Pages from Railcast
Jean-Sébastien D. wrote in post #1069202:> Jim Oser wrote in post #1069201: >> Other people have reported this error:Thanks. I am wondering if its actually possible to see into the application controller other resources Example class ApplicationController < ActionController::Base protect_from_forgery include SessionsHelper @pages = Page.all end app/layout/_footer.html.erb <% @pages.each do |page| %> <li> <%= @page.name %> </li> <% end %> Thanks in advance -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.