trying to use in rails3.2.14 and ruby 1.9.3
added gem ’preferences’ to Gemfile and did bundle install
And as per the gem document I do the following step
rails generate migration create_preference
ran rake db:migrate
restarted rails server
added some preference to user model
preference :publish_profile, :default => true
But when tried to access a preference using
#user.prefers_publish_profile
I got uninitialized constant Preferences::InstanceMethods::Preference
Here is the gem url:-
https://github.com/pluginaweek/preferences
The problem will besolved by using rails3 branch gem
gem "preferences", :git
=>"git#github.com:skyeagle/preferences.git",:branch =>"rails3"
Thanks
Related
I'm following some tutorials of association in rails database, the first step is to create the app with rails new newProject -B. Then i create the two models with rails g scaffold Father name:string and rails g scaffold Child name:string sex:string father:references.
After that i try to create the database with the command rake db:create, but an error appears:
Could not find nokogiri-1.6.7.1 in any of the sources Run bundle
install to install missing gems.
I run the command bundle install normally, but when i tried again, the same error appears.
I tried to insert in the GemFile gem 'nokogiri', '~> 1.6', '>= 1.6.7.1' and the same error persists.
I had a similar issue with nokogiri a couple of months ago.
I solved it by adding '-rc3' to the end of the gem version, like this:
gem "nokogiri", ">= 1.6.7.rc3"
I've had this problem a few times before, you can try installing the gem manually using gem install nokigiri
Have you try
$bundle update
?
Can you post the error logs to see if it is a Permissions Error or something else?
I have written my own Gem called date_ninja which makes sure a date is returned in the correct when passing a date from excel. Testing the gem it works fine. For example opening irb, and calling require 'date_ninja' returns true and I am able to use.
DateNinja::DateDojo.date_format_validation(value).
This will either return an date or an exception.
In my Rails App, I have added the gem to my gemfile as so:
gem 'date_ninja', git: 'git#github.com:mpowered/date_dojo'
I then ran bundle install but when I use it, I get this:
DateNinja::DateDojo.date_format_validation(56423)
NameError: uninitialized constant DateNinja::DateDojo
from (pry):5:in `<main>'
If I open the Rails console and see if I can require 'date_ninja' it => false so I am guessing its not loading my gem even though I have bundled it. Am I missing a step?
Can you try replacing the line:
gem 'date_ninja', git: 'git#github.com:mpowered/date_dojo'
with
gem 'date_ninja', path: 'local/path/of/ninja'
If this works then something is not well set with git.
Rails 3.1 suggests running
rails generate session_migration
However this generates the exact same migration as
rake db:sessions:create
but none of the commands are recognized by my setup using rails 4.0
errors are :
Could not find generator session_migration.
and
Don't know how to build task 'db:sessions:create'
respectively.
I have run:
gem install 'activerecord-session_store'
How do I make it work so that i can store a shopping cart bigger than 4kb?
The ActiveRecord session store has been extracted out of Rails into it's own gem as part of Rails move towards better modularity. You need to include the gem as shown below in your Gemfile to get access to the rake task and related functionality.
gem 'activerecord-session_store', github: 'rails/activerecord-session_store'
The gem
The Rails commit where the change happened
A bit of an explanation
See the README of the gem linked above for more instructions, but you still need run the following command after installing the gem
rails generate active_record:session_migration
and after that you need to modify the config/initializers/session_store.rb to look like something like this
MyApp::Application.config.session_store :active_record_store, :key => '_Application_session'
or
Rails.application.config.session_store :active_record_store, :key => '_Application_session'
depending on your Rails version.
I'm trying to run Redmine on Heroku. Redmine returns a 500 error, presumably because my rake db:migrate fails:
at /app/lib/tasks/email.rake:170
rake aborted!
undefined method `has_key?' for nil:NilClass
The Heroku stack is bamboo-ree-1.8.7. Here's my Gemfile:
source :gemcutter
gem 'i18n', '0.4.2'
gem 'rails', '2.3.11'
gem 'coderay', '0.9.7'
gem 'rack', '1.1.1'
gem 'rake', '0.8.7'
gem 'rubytree'
How do I get heroku rake db:migrate to work?
you should lock your rubytree gem to 0.5.2
try this
gem "rubytree", "0.5.2"
I got this to work by doing two things.
First, I followed some suggestions from http://bayleshanks.com/tips-computer-programming-redmineOnHeroku (specifically I added the suggested line to config/environment.rb and created a blank file called public/plugin_assets/README).
Second, I modified the Gemfile to specify rubytree version 0.6.2, ran bundle install, re-committed the Gemfile.lock into git, and pushed to Heroku.
I'm not sure the earlier steps were necessary, but the database migration finally worked and Redmine is now running.
+1, the above worked for me as well, after satisfying a number of other dependency problems. Ideally, someone should write up a good HOWTO on deploying Heroku, though Ruby/Rails is such a moving target, it would likely only be accurate for a few minutes.
With a new Rails 2.3.10 project, the file config/environment.rb has the following line commented out:
# config.gem "sqlite3-ruby", :lib => "sqlite3"
but for some reason, I tried a scaffold foo, and start the rails server, and the app is running.
I thought the requirement is, every gem the app needs, it has to be listed in config/environment.rb?
In Rails 2.3, it's enough to have the gem installed on your system for you to use it.
In Rails 3, you must have the gem listed in your Gemfile and installed via bundler to use the gem.