partials

Missing template after link_to_remote

I'm using link_to_remote to update a partial on my page. The problem is that Rails isn't finding my partial. I am specifying the full path to my partial(an html.erb file) in the controller method: def my_method create something render :partial => '/shared/partials/my_partial_form', :layout => 'false' end I know the controller met...

rails html helper

I'm trying to figure out the cleanest way to generate a bit of html AND nest content inside it. Using HAML. Basically I want to do something like: = block_large This is some nested content And that should generate: <div class="block large"> <img src="block_large_carat.gif" class="block_large_carat"> This is some nested content...

Zend Framework - shared view script path ( global partials )

How is it possible to set up a shared view script path for partials to create global partials within the Zend Framework? We know that you can call partials between modules e.g - echo $this->partial('partial_title','module_name'); but we need to set up a partial folder in the root ( i.e below modules) so that it can be access...

Zend Cycle within Partials

Is there an alternative to using 'Cycle' when creating zebra tables in Zend. ( My version does not have Cycle helper and don't really want to have to upgrade. Using a partial loop and need each table to put out different bg color. However the partial loop doesnt seem to act as a standard loop with no repeat ...

Rspec partials problem

Hi All, I am writing specs for View, that has a menu (which is in a partial) rendered in layout. I want to write specs for selected menu. Here is the code it "should have User Administration link" do template.stub!(:render).and_return(:partial => "layouts/admin/menu") do_render #render :partial => "layouts/admin/menu" #do ...

Calling a rails app's main 'yield' from a partial

Hi, my question is very simple. I will ask it first incase the answer is obvious, and then I will explain what I mean, incase it's not obvious. Is it considered ok to make your main 'yield' call from a partial instead of doing it directly from your layout.html.haml file? Does doing so result in any kind of perforance loss. Explanat...

Consolidate multiple views into one view without coupling?

Let's say I have: object A, B, C each with corresponding models, views, and controllers How would you load them all into one view (site index)? You could use a partial of each model's index, but then methods of that particular controller don't get called so you would have to add that view's methods. Any other suggestions? Thanks! ...

Managing CSS in large Rails projects

What are some good methods for handling CSS in large Rails projects? Ideally I'd like to be able to include CSS or a link to a CSS file per partial. I've played around with using content_for and yields which allows me to insert CSS into the head of the page with partials that are located elsewhere, however some partials get used more th...

Rails: What is the best way to seperate two very similar views?

I have a controller that has two actions: "show", "show_modify". These have very similar yet slightly different views, i.e show_modify has different div classes, has extra links/buttons and so on. From what I've seen there are a few ways to approach this in rails: Make one template for the two and just add conditions inside: <% if par...

optional local variables in rails partial templates: how do I get out of the (defined? foo) mess?

I've been a bad kid and used the following syntax in my partial templates to set default values for local variables if a value wasn't explicitly defined in the :locals hash when rendering the partial -- <% foo = default_value unless (defined? foo) %> This seemed to work fine until recently, when (for no reason I could discern) non-pa...

Rails partials: help with require

I'm fairly new to Rails and am trying to figure out how to add a method to the String class and have the code in my partial know that the String class has been added to. I'm not sure where I should put the require statement. ...

Rails partials: Trouble finding where to put reference to new method in my partial

I'm fairly new to Rails and am trying to figure out how to add a method to the ActiveView class so I can then access a new method from the partials. Here's some sample code: %li =link_to "#{h aim_small.description.shorten} #{"(current aim)" if aim_small.description == current_aim.description}", :action => 'show', :id => aim_small ....

Rails syntax for comments in templates: is this bug understood?

Using rails 2.3.2 I have a partial _foo.rhtml that begins with a comment as follows: <% # here is a comment %> <li><%= foo %></li> When I render the partial from a view in the traditional way, e.g. <% some_numbers = [1, 2, 3, 4, 5] %> <ul> <%= render :partial => "foo", :collection => some_numbers %> </ul> I found that the <li> and ...

Two-part Rails layouts

My web pages consist of two parts, let's say top and bottom (except header and footer -- those are consistent across pages). What is the best practice to dynamically generate those parts depending on the action? One approach I have come up with is to have view for the top and partial for the bottom; in the layout call yield for the top ...

Including partial template

Hi In sinatra's app, require 'rubygems' require 'sinatra' require 'haml' get '/new' do haml :new end get '/edit' do haml :edit end __END__ @@ layout %html %head %title %body = yield @@ _form # partial form @@ new %h1 Add a new item # require partial _form @@ edit %h1 Edit an existing item # require partial _form ...

Where to put partials shared by the whole application in Rails?

Where would I go about placing partial files shared by more than one model? I have a page called crop.html.erb that is used for one model - Photo. Now I would like to use it for another model called User as well. I could copy and paste the code but that's not very DRY, so I figured I would move it into a partial. Since it's shared betw...

Why doesn't my linq to sql generated classes have OnCreated()

Hi, I've been reading over the internet about a partial method that I can use called OnCreated() to run some logic against my Linq - SQL class while it is being created. How ever there is no partial class by that name for me to use. I'm sure I'm missing something small here. Here is what I'm trying to call in the partial class partial...

Rails Many to Many Relationship with occasional Nested Routes

As I am learning more about rails, and breaking my design thinking from ASP.Net days, I was considering a scenario this morning but did not know if it was possible to do. Practitioners have many Treatments through services - and vice versa In my control Panel I have an area for Practitioners to edit their details (names, contact info e...

Zend Framework :: extending action variable scope for partials

Hi, I want to know if there exist any other way through which we can access the controller name, action name and other variables inside a partial. In other words, I want to extend the scope of my action variable to be accessed inside the partial templates rather than passing the lot along with the call to partial template. Thanks -Dev...

Modular Zend Framework with a base of partials

Hello, Currently I'm finding I have to keep duplicating partials for different modules. I would like to have a case directory for all partials to be accessed. Does anyone have a good way of doing this? Thanks ...