similar to: Accessing View methods from Model?

Displaying 20 results from an estimated 20000 matches similar to: "Accessing View methods from Model?"

2009 Jun 11
4
Using view helpers and route helpers in a model
Hi there, I am trying to get something working and its driving me crazy. I have been looking around for solutions to getting view helpers working in models and for the most part I find this solution. Add the following in the model you want to use them in include ActionView::Helpers::UrlHelper include ActionController::UrlWriter However, when I try something like
2006 Jan 04
2
Navigation Helper
I am attempting to integrate a main navigation section into my web application. Naturally the easiest and DRY way to do this would be to either include it in a layout, or as a partial. The only problem is that I want the link for the current page to have its own css id ("current"). The only way I can think to accomplish this is to just include the navigation in every page, but this is
2007 Dec 23
1
Rails: possible routing discrepancy
Hey all, I''m seeing a strange behavior in my spec that I can''t account for. I''ve got a route that looks like this: map.writing \ ''/writing'', :controller => ''abstracts'', :action => ''index'', :index => { :select => ''all'' } and I have template code that looks like this: <br
2007 Nov 06
2
Why is this view spec failing?
I can''t figure out why I am getting a failure. It renders out fine in the browser. <h1>New member</h1> <%= error_messages_for :member %> <% form_for(:member, :url => members_path) do |f| %> <fieldset> <legend>Member Info</legend> <p><label for="member[first_name]">First Name:</label> <%=
2008 Sep 30
0
Tabbed Menus - link_to_unless_current
This is more difficult than I originally anticipated. Any help in figuring this out is most appreciated: This is a code snippet from my header.rhtml (or erb) file that draws tabbed menus: <ul> <% [["Home", "/home" ], ["Positions", "/company" ], ["Leads",
2004 Jan 07
11
Random ping jumps
Hello, I''ve got this problem. There is an linux server with 2.4.24 kernel and pinging from him to internet (or from lan) ping randomly jumps up: 64 bytes from fortas.ktu.lt (193.219.160.131): icmp_seq=387 ttl=59 time=30.0 ms 64 bytes from fortas.ktu.lt (193.219.160.131): icmp_seq=388 ttl=59 time=32.6 ms 64 bytes from fortas.ktu.lt (193.219.160.131): icmp_seq=389 ttl=59 time=34.9 ms
2006 Sep 05
1
Named routes and current_page? incompatibility
Hi, I have some named routes defined e.g. map.public and wish to use link_to_unless_current() to disable link. However, as I''ve seen from forum discussions and the API doc, the issue lies with the fact that the named_route_url() method generated by a named route does not default to only_path = true like url_for. Therefore, the current_page? within link_to_unless_current() will not
2006 May 10
2
newbie q on displaying a db field value in the view
My layout calls a few links like so: <%= link_to ''| Home '', :controller => ''search'', :action => ''''%> <%= link_to ''| Search '', :controller => ''search'', :action => ''''%> I would also like to display two values from my user table in the same layout right after the
2010 Mar 11
4
Call a controller method from a view
Hi, I am trying to call a controller method from my view, but I get an error and I don''t know how to correct it. What i am trying to do: I am in the edit form of the model Product, and products can have many ingredients. So on my edit form there is a text_field where you type the ingredient with a link "Add" which is supposed to add the typed ingredient to the current
2006 May 11
3
can''t call link_to from within a model class
can anyone tell me how to call link_to from within a model class? I''m trying to do something like the following: validates_uniqueness_of :email, :message => "address has already been taken. If you''ve forgotten your password, please click " + link_to(''here'', :action => ''forgot_password'', :controller =>
2008 Oct 16
3
Rails: View specs and implicit parameters in link_to()
Hi all, I''ve been cleaning up our routing file, and removed the default map.connect ":controller/:action" route. It''s thrown up a bunch of sloppy mistakes, which is great, but I also think I''ve found a problem with the view specs. We have a generic navbar partial which is rendered in the index page of several different controllers. The navbar contains
2007 Jul 30
2
build a menu (li.selected)
Hello, when I try to create a menu I found the following limitation: the event li.selected does not work and, I am not being able to show an image when the menu option is selected in my CSS exists the following code: .menu li.selected { ... background: transparent url(/images/menu_selected.gif) 100% 1px no-repeat; ... } in file: ...\layouts\application.rhtml exists the following code: <div
2006 May 21
6
Is there a way to call helper methods in a controller?
Hi, Is there a way to call helper methods in a controller? I want to do something like this in my controller Class MyController < Action.... def my_method string = link_to "some_url", :controller => "home", :action => "command" end end link_to is an ActionView helper method and it seems that I couldn''t access the method in the controller
2007 Jul 06
3
stubbing helper methods for View specs
Hi there I have several view specs, that include the following snippet in their "before" block to stub the methods by acts_as_authenticated before :each do @u = mock_model(User) @u.should_receive(:name).and_return("Hans Muster") template.should_receive(:logged_in?).and_return(true) template.should_receive(:current_user).and_return(@u) end this
2005 Jan 24
1
how can i override the show view to capture show/n , show/n+1, etc.
Hi - Yet another rails newbie ... I have a simple list view rhtml with data returned from a db and displayed within a table. Each row has a show action link_to based on the id field in the table row. i.e. http://127.0.0.1:3000/myapp/show/1 http://127.0.0.1:3000/myapp/show/2 http://127.0.0.1:3000/myapp/show/3 I want to override the default show view but I don''t understand how I can do
2003 Nov 26
3
Fair queueing: SFQ vs TBF
Hello, I have one Q. What is better when using as leaf in one leaf with several hosts (like subnet) to splice traffic equaly to user number? Like 2 users = 256/2, 3 = 256/3 and so on. WRR was pretty good for this job, but it''s only for 2.4.21 kernels and mine''s 2.4.22. So what is better: SFQ or TBF? -- Artūras Šlajus _______________________________________________
2006 May 28
2
"if" clause in the view - - - (for two objects)
Hi, sorry to bother you guys with a simple sytnax question; i have a loop of objects taking place (ie, for page in @pages....xxxxxxx....end) and a link associated to each pages so that in the end it looks like this: page1 (link) page2 (link) page3 (link) . . . page n (link) (all of this done by putting a simple ''link to'' in the for loop.) now i need to seperate two pages
2006 Feb 18
5
Model methods and partial view templates
I have a method in a controller that invokes a render :partial => ''some_partial_view'' In that view, I''m trying to access a method defined in a model, like this; <% for view in @an_array %> <% local_var = view.some_method() %> <% another_var = view.a_column_name %> etc.. I am getting an undefined method error but the model is accessible
2005 Jul 22
1
A Bit Baffled By text_field
Hello. I am converting my Java app to Rails and I''ve hit something that has me a bit baffled. I''ve been fiddling with this for over an hour and trying many different combinations so at this point I''ve lost perspective. It''s probably something simple but I can''t see it anymore. I have a component that looks like this: <% for advertiser_category in
2005 Jul 13
1
link_to_unless_current woes...
Hi ! I have the following in my navigation area: <%= link_to_unless_current image_tag(''events.gif'', :height => 34, :alt => ''Events''), :controller => ''events'' %> Works nice untill I am on the events page, in which case the generated code looks like: &lt;img alt=&quot;Programs&quot; height=&quot;34&quot;