actionviewhelper

Rails: Preselect a value in ActionView-Helper 'collection_select'

I'm trying to get the ActionView-Helper collection_select to take a value that will be preselected in the dropdown-menu. Neither (:selected in the html-option-hash) <%= collection_select(:my_object, :my_method, @my_collection, :id, :description_string, {}, {:selected => @my_collection_object.id}) %> nor (:selected in the option-hash)...

Rails form_tag form writing - with non-active record model

Hey Rails People, I'm somewhat of a Rails newbie. I'm writing a couchrest-rails app, so am not using activerecord for this model. I just figured out that that means that form_for(@model) won't work. I'm trying to work out how to use form_tag -- but most of the examples don't involve new & create actions. This is wrong: <h1>New ...

How can I programatically determine which methods have been declared as "helper" methods by a controller in Rails?

I'm writing a plugin that adds a method to controllers and declares it as a helper method. If it were done statically (rather than through the plugin), it would look something like this: # in RAILS_ROOT/app/controllers/stuffed_animals_controller.rb class StuffedAnimalsController < ActionController::Base private def bear 'Teddy...

How can I stop the password field being pre-populated on edit?

I have this problem all the time in my rails apps and I still need the correct solution. Whenever a user edits their own record the password field is being populated. I suspect its Firefox as setting @user.password = nil in the edit action doesn't help. The problem is the password confirmation isn't populated so validation fails due to ...

Rendering a Rails view to string for email

I'd like to send emails from a table every night at midnight, so I've created a model to track all communications to be sent. This Communication model stores who the letter is to, from, and the contents of the letter to be sent as html. The user enters a criteria to match for whom the letter is intended: state, country, favorite color,...

How to call 'time_ago_in_words' from a FunctionalTest?

I'm using 'time_ago_in_words' function in a view, and I need to test the output in the FunctionalTest. But the test can not see 'time_ago_in_words' helper function. What should I do in order to use these helper methods from FunctionalTests? ...

how to add styles to actionview helper tags?

how do i add styles to actionviews helper tags. like the following <%= link_to "Home", :controller=> "home", :action=> "index", :style=>{:position=>"absolute", :top=>"0px"} %> is something like the above achievable. I dont want to add css classes. Thanks. Update-- sorry Salil. it doesn't work for link_to_remote. I need a solution th...

RoR: undefined method `url_for' for nil:NilClass

I have a standard Rails application. When a Tip is created, I would like to create a Message for each User who is interested in that Tip. This sounds simple right? It should be... So, we start with a Tip Observer: class TipObserver < ActiveRecord::Observer def after_save(tip) # after the tip is saved, we'll create some messages...

Using helpers in rails 3 to output html

Guys, I'm trying my best to build a helper that outputs a <'ul> consisting of all the members of a collection. For each member of the collection I want to print out a <'li> that has a title, and a div of links to CRUD the member. This is pretty similar to what Rails outputs for scaffolding for the index view. Here is the helper I've ...