Question

I've built a model called "Subject" in my Rails 3.2 application. I used the scaffold command below.

rails g scaffold Subject subject singular:boolean gender:integer subject_masculine subject_feminine subject_neuter language:references --skip-stylesheets

The scaffold runs almost to the end, but then gives a mysterious error about the helper:

The name 'SubjectsHelper' is either already used in your application or reserved by Ruby on Rails. Please choose an alternative and run this generator again.

I've tried reversing the scaffold and rebuilding. In the end I just built the table and it seems to be working ok. There is no helpers/subjects_helper.rb file, but I don't expect to need a helper for this particular model.

I could not find subject among any reserved word list, but that in itself was a problem. Another SO post has been raised on this issue.

List of reserved words in rails *3*

Why am I getting this error, and can I just ignore it?

EDIT

My Gemfile as requested

source 'https://rubygems.org'

gem 'rails', '3.2.8'
gem 'thin'
gem 'sinatra'
gem 'pg'
gem 'simple_form'
gem "nested_form"
gem 'thinking-sphinx'
gem 'devise'
gem 'haml-rails'
gem 'ruby_parser'
gem 'html2haml'
gem 'best_in_place'
gem 'carrierwave'
gem 'fog'
gem 'seed_dump'
gem 'bluecloth'
gem 'redcarpet'

group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'
  gem 'prototype-rails'
  gem 'uglifier', '>= 1.0.3'
  gem 'twitter-bootstrap-rails'
  gem 'therubyracer'
  gem 'less-rails'
  gem 'jquery-datatables-rails'
end

gem 'jquery-rails'
gem 'social_stream'
gem 'rails-footnotes', '>= 3.7.5.rc4', :group => :development

group :development do
  gem 'rails-erd'
  gem 'quiet_assets'
end

gem 'vestal_versions', :git => "git://github.com/futurechimp/vestal_versions.git"
gem 'diffy'
gem 'diffrent'

EDIT2

As per Philip's suggestion, I ran the Module.constants command from the Rails console. Amongst the output, there were two 'subject' values:

:SubjectsHelper
:Subject

I check several times there is no helper, so I decided to add one. I created the helpers/subjects_helper.rb file, with the following code:

module SubjectsHelper
end

Rails has now rebooted OK. I still don't understand what happened though.

Was it helpful?

Solution

As you correctly say, SubjectsHelper is already provided by Social Stream. See:

https://github.com/ging/social_stream/blob/master/base/app/helpers/subjects_helper.rb

Your solution is working because you are reopening the module, which is a valid action in Ruby.

OTHER TIPS

I found it. I am using the Social Stream gem, which has a subject in the routes.

subject_lrdd        /subjects/lrdd/:id(.:format)

It must be buried in the engine somewhere.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top