ruby-on-rails3

Error calling Dispatcher.dispatch #<NameError: uninitialized constant ActionController::CgiRequest

I'm getting the following error on log/mongrel.6001.log I'm using mongrel_cluster , rails 3 and ruby 1.8.7 I start mongrel_cluster using mongrel_rails cluster::start But when I try to access the page on browser I get the error bellow "Error calling Dispatcher.dispatch # Mon Oct 11 00:26:04 -0500 2010: Error calling Dispatcher.dispat...

ActiveRecord::Relation error

Error from Rails, does this make sense to you? <%= @permission.inspect %> outputs: [#<Permission project_id: 3, role_id: 2, user_id: 13>] <%= Role.find(@permission.role_id) %> undefined method `role_id' for [#<Permission project_id: 3, role_id: 2, user_id: 13>]:ActiveRecord::Relation This doesn't work either for some reason: @permis...

devise simple registration form

The user fills in the form his email and password. After submiting the form, the user recieves an email, containing a activation link. After clicking on that link, he comes to an form, where he can fill out the rest of his data (login, gender, age and so on...), before he does'nt correctly fills out the form, he is not allowed to log in....

Ruby on Rails 3: How to access current_user within model

I have an Activities model that acts as sort of a dashboard for the entire rails app I have. I have some :after_create callbacks passing the Customer object and a generic message into the Activity model to store the information. This works fine and dandy by outputting "has created customer Microsoft in the Toolbox." but I can't seem to f...

how to pass html_safe strings in js render partials

I have a rails 2.3.9 application that i'm migrating to rails 3. As almost everyone, i'm having problem with rendering strings, specially JQUERY scripts that were inline. Before, that somebody tells me that in rails 3, it changed, i cannot rewrite all my scripts now. I will do it, it will be scheduled, but for now, i want to make it work...

HTML escaped in Rails 3

I have a method call in my view like this <%= Navigation.with(params) do |menu| if current_user && current_user.can_verify? menu.item("Listings", manage_listings_path()) menu.item("Listing changes", needing_change_approval_manage_listings_path()) menu.item("Flagged Items", f...

Advice about Rails 3 - Routes - Restfull

I'm building a app to manage some products, so I have a Product model. We sell, buy and when a product breakes, we send it to the manufacturer for repair. So, I've created a Movimentation model, that will take care of all ins and outs of a product. When we bought a product, a In record is generated for each product on the Movimentatio...

Rails 3 - How to Not to Error if no record is found

In my permissions controller, I use Active record to look for a permission: @permission = Permission.find(params[:user_id]) If this returns a result I then look up the permission.name And pass this to my controller. Problem is sometimes this does returna result, othertimes it does not. When it does not, it errors. How can I prevent t...

Form_for a Nested Resources Permissions (Y Model)

Hello, could really use your help, understanding this complex rails issue I've been banging by head against the wall on... I have the following Models: Permissions (user_id, role_id, project_id) Roles (id, name) Projects (id, name) Permissions is the Y model for Roles and Projects. I'm struggling to make a form to allow a user t...

How can I optimize this situation with ActiveRecord (Rails 3)

Let's say I have the following association: Club has_many users User has_many guns Gun has_many bullets Club: Moe, Larry, Curly Moe: 2 guns gun 1 has 100 bullets gun 2 has 20 bullets Larry: 1 gun gun 1 has 40 bullets Curly: 2 guns gun 1 has 20 bullets gun 2 has 10 bullets Now, I want to find out how many bullets in the CLUB. It'...

page_cache_fu error

I am getting an error when I am starting rails server in rails 3.. undefined method `to_prepare' for Dispatcher:Module (NoMethodError) How to solve this issue ? Please help ...

How to generate documentation with Yard for Rails views?

I have just started using Yard to generate my docs and whilst it works great for my models and controllers, I can't seem to get it to generate anything for the views I've tried a variety of different ways to get it to work. Currently I've set up a rake task to generate the docs that looks something like this YARD::Rake::YardocTask.new...

Turn on html_safe for the entire app in Rails 3

Rails 3 turns off the html_safe option by default. I want to revert this thing. I have a rails 2.3.8 app getting converted to rails 3. Almost every page breaks because of the rails3 default html_safe setting. Is there any way I can revert this to where it was in previous versions of rails ? Please help ...

Alternative for ssl_requirement plugin for Rails 3?

I have used ssl_requirement plugin for previous versions of Rails and it is awesome. But for Rails 3 I want to try out some new plugins or gems. Any suggestions? ...

Stubbing all views in a config.before block in RSpec2, Rails3

I have this in my spec_helpers.rb file: config.before(:each, :type => :view) do @widget = Factory(:widget) view.stub!(:widget => @widget) end @widget is accessible in my views, but the view.stub! part returns: undefined method `_routes' for nil:NilClass /Users/mdarby/.rvm/gems/[email protected]/gems/activesupport-3.0.0...

Problem with routing rails 3.0.0 and --force-plural

Hi, sorry for bad English. For example i execute script/rails generate scaffold goods title:string --force-plural Then i follow to http://localhost:3000/goods/new and got error undefined method `goods_index_path' for #<#:0x7f1e7cb32530> I found some line involved in this behavour in polymorphic_routes.rb, but can't understand what ...

Using Ajax in Ruby Forms, form_remote_tag

Hello, all, I am a little stuck on a exercise I am trying while learning RoR. I have a form I want to submit to my controller and have the results populate a div tag further down. I have rails 3.0 and ruby 1.8.7. When I try the following: Ajax List Demo Listing posts <%= javascript_include_tag 'prototype' %>...

Undefined method/NoMethodError in Rails 3

So I am doing a lynda.com Rails essential training tutorial, and I am getting an error that the video tutorial does not. I assume this has to do with the different versions of Ruby & Rails that I am using (the latest as of today) as opposed to the ones they used when this was recorded (I think in 2007). This is what my controller looks ...

Help with JQuery autocomplete in rails3

Hello. I'm having difficulty setting up JQuery Autocomplete with Rails3. I don't get any errors, it just behaves like regular text box. Here is what I have done: First I installed autocomplete as explained here: http://github.com/crowdint/rails3-jquery-autocomplete#readme I have a model class which contains the model which will be ...

What is the Rails3 equivalent of start_form_tag?

Newbie here...I am just going through, what is clearly, an old rails tutorial. To create a form they have the following code: <%= start_form_tag(:action => 'create')%> <%= text_field(:album, :title) %><br /> <%= text_field(:album, :artist) %><br /> <%= text_field(:album, :genre) %><br /> <%= datetime_s...