similar to: Is there a way I can create a sub-layout with ERB?

Displaying 20 results from an estimated 7000 matches similar to: "Is there a way I can create a sub-layout with ERB?"

2011 Apr 13
3
Question about ERB performance
I''m trying out rails 3 and I''m looking at the performance statistics given by WEBrick. It says many of my database operations are taking 2ms or 7ms... but the view is taking 40ms. People often say that the database is the bottleneck in applications (which it most certainly can be, and often is)... but isn''t the rendering of ERB a little show here? My test pages really
2011 Mar 09
1
" 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() {
2011 Oct 12
4
How to access controller's instance variable in a js.erb loaded by javascript_include_tag?
Hello! In rails 3.1 app I have a controller UsersController with ''show'' action. show.html.erb contains: <% content_for(:head) do %> <%= javascript_include_tag ''myscript'' %> <% end %> <p>Hello @user.name</p> And I have this in myscript.js.erb $jQuery(document).ready(function() { alert(<%= @user.name %>); }); @user is being
2011 May 27
14
[rails] undefined method `model_name' for NilClass:Class
Never seen the error above before, code: describe "edit action" do it "edit action should render edit template" do food = Food.create(:name=>''mooo'') # Food.any_instance.stubs(:valid?).returns(true) get :edit, :id => food.id response.should render_template(:edit) end end -------------- next part
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> <title>Todo List</title>
2008 Jan 24
3
Help to spec a rails helper method that uses content_for
Hi guys, I am a Rspec newbie and am having problems creating a spec for a RoR helper method. 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
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 primary content wrapped in generic <html> and
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=?]",
2011 May 21
2
How do you create a sub-layout or a partial that wraps a lot of custom html?
Basically I''d like to create a layout inside of a layout using erb. Something like this: <%= render :partial => ''support'' do %> <div id="helpDocumentView"> <h3><%= @help_document.question %></h3> <%= @help_document.content %> <div id="helpDocumentHelpful" data-help-document-id="<%=
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
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(:partial =>
2010 Jan 31
3
Append/Prepend to a template from controller method
I want a method in app/controllers/application.rb that can prepend/append text to whatever template gets rendered. Of course I can''t call render twice w/o getting a double render error, so is this possible? I want to redirect after a delay using a meta refresh. Here''s what I''ve got: app/controllers/application_controller.rb: def redirect_after_delay (url, delay)
2007 Oct 09
23
Testing layouts with RSpec on Rails
Hey guys, Does anyone have any wisdom to share on the subject of speccing Rails layouts? Most of it''s plain old view specs stuff, but are there sensible ways to verify things like the yield call? (Mocking doesn''t catch that) Thanks, Matt -- Matt Patterson | Design & Code <matt at reprocessed org> | http://www.reprocessed.org/
2011 May 28
4
how can I investigate when a rspec test fails?
For example: it "re-renders the ''new'' template" do # Trigger the behavior that occurs when invalid params are submitted Sector.any_instance.stub(:save).and_return(false) post :create, :sector => {} response.should render_template("new") end I have the new template under app/views/sectors but the test says: SectorsController POST
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 Sep 13
2
<meta http-equiv="refresh" content="5"/>
Do you know of any way for me to stick a meta tag in using a before_filter or after_filter or around_filter? <meta http-equiv="refresh" content="5"/> I have been trying to figure out out and just cannot make sense of it. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails:
2006 Jul 25
6
DRY question (newbie)
Say i want to include the same chunck of text (a menu on a webpage for example) on each page. Is there a method by which I can save the HTML in a text file and call it up later? Is there a better way? I know ruby has "puts" but i can''t use that b/c it does not work with my webhost (dreamhost.com) Any suggestions? -- Posted via http://www.ruby-forum.com/.
2007 Jul 05
6
mocking methods in the controller.
Hi, I''m very new to rspec so please be patient with me. I''ve tried to take some of my tests out of the controller specs to check for things that are rendered. This has not worked so well, since my views have the controller method current_user in quite a few places. Is there any way that I can define this so that my views will be executed? Will this same thing occur for all
2010 Jan 18
7
Ruby Array to Java Script Array
Hi, How can we use an array created in Ruby in Java script ? Regards, Prashant -- 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
2007 May 09
5
layouts + routes = confused
I''m new to RoR and the tutorials I''ve found on the web, while helpful, aren''t as "complete" as I''d like them. I understand the basics when it comes to layouts and routes, but I''m trying to get them to work together. MY first task was to implement a user authentication system (registration/login/logout/change_password). This works fine with