search for: content_for

Displaying 20 results from an estimated 67 matches for "content_for".

2007 May 23
4
content_for
Any ideas how I would go about writing specs for views which make use of content_for? I''d like, for example, to be able to specify that ABC view places XYZ in the sidebar, which I do using content_for(:sidebar). Am I missing something obvious? Kyle
2008 Apr 19
4
Is testing output within content_for possible?
I wanted to test that the links below were being rendered in the views. - content_for :sidebar do %ul.links %li= edit_link edit_admin_contact_url(@contact), "Contact" # view test it "should have the correct side bar links" do do_render response.should have_tag("ul.links") do with_tag("a[href=?]", edit_admin_acco...
2008 Jan 24
3
Help to spec a rails helper method that uses content_for
...hod. I have in fact already implemented the helper method and am trying to create retrospective specs. I know its the wrong way to do it but I am still learning Rspec. In my view I have a call to a helper method. <% body_class "users" %> which sets a CSS class declaration in the content_for block which is then used in the <body> tag in application.html.erb layout. def body_class(class_name) content_for(:body_class) { " class=\"#{class_name}\"" } end I was trying the following in my view spec: template.should_receive (:body_class).with("users&...
2007 Jul 16
4
Accessing content_for html in view specs?
Hi All, Hope all is going well. I''ve got a few views that create some content using ''content_for'' blocks <% content_for :blah do %> ..... <% end %> Has anyone worked out a way to be able to access the html that''s generated inside those blocks? Since they''re not part of the view, have_tag('''') seems to miss them, and at the moment...
2010 Aug 18
2
RSpec 2/Rails 3 - content_for in view specs
My main layout includes separate content_for/yield sections for my header, sidebar, footer, and content. However, when running a view spec, the `rendered` variable seems to only contain a string of just the primary content and ignores the header/footer/sidebar as well as the rest of my layout file (the "render" call just returns my...
2008 Sep 17
2
Layouts and content_for
when i studied the tutorial about layouts & content_for from railscast.I need a clarification as per their tutorial. url:http://railscasts.com/episodes/8-layouts-and-content-for <!- projects/index.rhtml -> <% content_for :head do %> <= stylesheet_link_tag ‘projects’ %> < end %> <!- layouts/application.rhtml -> <head&g...
2010 May 05
2
Add method to get at captured content_for
In Rails 3 the only way to get for content captured with the content_for method in a view is to call yield from within a view. However, sometimes is it useful to get to this data from within a helper (for instance to provide a default value). Calling yield from within the helper method won''t work, and accessing the @_content_for variable directly is not encoura...
2006 Apr 27
0
partials and content_for
let''s say i''ve got a partial that looks like this: <% content_for :foo do -%> partial.id <% end -%> then the following works: <%= render :partial => "partial", :collection => @collection %> <%= @content_for_foo %> but this does not: <%= @content_for_foo %> <%= render :partial => "partial", :collect...
2006 Jul 13
5
Generic page element display initializer in a layout?
All, I''ve run into a snag. I need to handle the display of elements on my page and I want to use my Javascript event handlers on page load. However, my BODY tag is trapped in my generic layout. I''m thinking that I can put an onLoad on the BODY tag that will just call a Javascript method called initializePage() and then provide this initializePage() call in my specific page
2008 May 19
0
How to fetch a block provided by content_for in a helper?
Hi, I got a title_tag helper that renders default page title or title provided by content_for block, if such block is present. Currently I call this method like this: "title_tag(yield(:title))". Is it possible to fetch :title block inside the helper without explicitly passing it as a parameter to this helper? --~--~---------~--~----~------------~-------~--~----~ You received this...
2010 Apr 30
0
Content_for & Capture helper
Hi, Whether content_for and capture helpers will work on ajax updates or in ajax pagination. Please help us. -- 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-ta...
2007 Sep 21
3
TextMate Bundle and exception when switching to alternate file.
...t. I''ve encountered a strange problem with the RSpec.tmbundle in trunk - namely that it was raising an exception when pressing ctrl-shift-downarrow (switch between spec and source - "Alternate File"). I tracked down the issue to be handling of the file_type in switch_command.rb#content_for() - the code expected the type string to be just ''spec'' when it can be ''view spec'' or ''model spec'' etc. Unfortunately I don''t know whether this is just an issue with my local textmate install or if it is, in fact, a bug. Here is a dif...
2011 May 26
8
Is there a way I can create a sub-layout with ERB?
I have 2 pages that have almost the same content except for stuff in the middle. I''d basically like to have a sub-layout that wraps the content that is different - exactly the way a normal layout file would. How can I call into a layout inside of erb? I''d like to do something like this: <%= render :sub-layout => "reusable-wrapper" %>
2011 Mar 09
1
&quot; instead of " in js code rendered by erb
Having problems rendering javascript in erb file. Thanks for suggestions. //layout erb file (function() { ... var widget_properties = {}; <%= content_for?(:extend_widget) ? "widget_properties = " + yield(:extend_widget) : '''' %> ... })(); //view erb file <% content_for :extend_widget do %> extend = { _init: function() { $("input[type=''checkbox'']", this).live(''clic...
2008 Mar 11
1
view spec on rails questions
Hi I have a couple of questions 1) how do you test the response inside a content_for block I see reference to it in the release notes but dont know where to find it (tried http://rspec.info/rdoc-rails/ ) 2) I dont seem to be able to stub partials in a different directory eg <%= render :partial => "foos/show" %> And I put this in the spec template.stub_render...
2006 Apr 04
3
Keeping javascript in the <head>
Given that Rails has built in ways to do almost everything else :) , is there a way to keep view specific javascripts inside the head tag of a layout without having to include that javascript on every page? -- Marlon -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060404/65e9bb6d/attachment.html
2006 May 23
11
adding layouts within layouts
Hi, I want to be able to have several layouts within each other so that I don''t have to keep repeating the layout code for one, in another. An example would be having a layout for the title of your web page and then having an embedded layout for the body portion in which the HTML for whatever view gets displayed. Is this possible? Thanks. -------------- next part -------------- An
2007 May 09
5
layouts + routes = confused
...x when at my url, so it''s the default page. The layout HTML looks like this: <html> ..... <body> .... <div id="menubar"> <%= yield :menubar %> ... <div id="main"> <%= yield %> ... Now in my views/main/index.rhtml I have: ... <% content_for :menubar do %> <% link_to "Login", :controller => "user", :action => "Login" %> <% end %> This works great and puts the link into the menubar div. Only problem now is that when i click it the site goes to /user/Login and I lose my layout. Is the...
2010 Jan 31
3
Append/Prepend to a template from controller method
...ant to add a redirect-after-delay, I add the following to 1) my controller and 2) the action''s view: app/controllers/my_controller.rb def my_action redirect_after_delay ''http://www.google.com'', 3 if some_condition end app/views/my_controller/my_action.html.erb <% content_for :refresh_tag do %> <meta http-equiv=''refresh'' content=''<%=@redirect_delay%>;url=<%=@redirect_url%>''> <% end %> <h1>Please wait while you are redirected...</h1> Since the content_for block never changes, would be nice to j...
2006 Mar 17
2
How to let the layout be more OO?
I am confused about the @content_for_layout.''cause it will display all the views in the layout.Do I have any methods to let the layout be more OO? I mean that for example,the app currently have more than one views to be displayed,but only some of them to be displayed at the same time at different <div></div> u...