Something like Textile for the posts feels pretty necessary, but this is giving me all kinds of headaches. bundle package and bundle install are both working fine, and confirm that RedCloth is set to the latest stable release (4.2.2). Right now I'm on ruby 1.9.2p0 and rails 3.0.7.
When I try to run a local server, though, I'm seeing:
LoadError in PostsController#index
no such file to load -- RedCloth
...
app/controllers/posts_controller.rb:1:in `<top (required)>'
This error occurred while loading the following files:
RedCloth
Line 1 in posts_controller is require 'RedCloth'. I haven't made any other changes to the basic Rails scaffold besides adding json formatting and a private authentication method, neither of which should be affecting this.
I'm using a partial to render my posts. It currently looks like this:
<% div_for post do %>
<h2><%= link_to_unless_current h(post.title), post %> </h2>
<%= RedCloth.new(post.body).to_html %>
<% end %>
Gemfile:
source 'http://rubygems.org'
gem 'rails', '3.0.7'
gem 'sqlite3'
gem 'rake-compiler'
gem 'RedCloth'
group :development, :test do
gem 'webrat'
gem 'rspec'
gem 'rspec-rails'
end
(rake-compiler is there from an attempt to follow these instructions, btw: http://www.ruby-forum.com/topic/484752 [I tried it with both ruby 1.9.1 and 1.9.2, no dice or else I wouldn't be here])
TIA :)
In your Gemfile, modify this line
gem 'RedCloth'
to
gem 'RedCloth', :require => 'redcloth'
Check gem installed like gem --list
Latest RedCloth version is 4.2.7 as i see in my gemset.
Try the latest for concern.
You have absolutely no need to require any gem in your controllers as they are already required via bundle.
Try to test in rails console is RedCloth available.
Related
We have a react-rails app. Unfortunately, the app works on local development but not when deployed to heroku. When going to our default path on the app, we get the following error:
ActionView::Template::Error (undefined method 'directory' for #<Sprockets::Manifest:0x007fef13200aa8>)
We've figured out that it happens at this line in our view:
<%= react_component('NavBar', {}, {prerender: true}) %>
A few things about our app:
It uses browserify to compile our js.jsx.
We precompile using RAILS_ENV=production bundle exec rake assets:precompile after deleting the public/assets folder.
Works locally with both rails s and foreman start
We are using boostrap-sprockets. Even when removed, we still have this issue.
Here is our npm dependencies:
"dependencies": {
"browserify": "^10.2.4",
"browserify-incremental": "^1.5.0",
"classnames": "^2.2.3",
"reactify": "^1.1.0"
}
Here is our Gemfile
source 'https://rubygems.org'
gem 'rails', '4.2.3'
gem 'rails-api'
gem 'spring', :group => :development
gem 'active_model_serializers', '~> 0.10.0.rc1'
gem 'pg'
gem 'devise'
gem 'puma'
gem 'twitter'
gem 'react-rails', '~> 1.0'
gem 'browserify-rails', '~> 0.9.1'
gem 'bootstrap-sass', '~> 3.2.0'
gem 'sass-rails', '~> 5.0', '>= 5.0.4'
gem 'autoprefixer-rails'
group :test do
gem 'rspec-rails'
gem 'pry'
gem 'faker'
gem 'webmock'
end
group :development, :test do
gem 'factory_girl_rails'
end
group :production do
gem 'uglifier'
gem 'rails_12factor'
gem 'rspec'
end
ruby '2.2.4'
We would appreciate all help.
The solution from hours of searching on StackOverflow and github issues seems to be to remove
//= require react_ujs
from your application.js in your assets folder.
I ran into this same issue just today and followed the suggestions in: https://github.com/reactjs/react-rails/issues/443#issuecomment-180544359. I was still running into an error so for now I modified my heroku configurations (config/environments/staging.rb & config/environments/production.rb) to use
config.assets.compile = true
for now and server-side rendering worked fine. The react-rails folks said they have a pull request completed to fix this issue but I dont think it has been released yet.
Potentially relevant: rake assets:precompile undefined method directory? for nil:NilClass
This is an error that occurs when the Rails asset compiler (Sprockets) cannot find a directory that you've specified as the location of an asset for your project. My suggestion is to make sure that all your assets are being successfully deployed to heroku, and then check that your paths are set up correctly when you reference assets in your project for inclusion in a page.
Also see Eric C's answer pertaining to React-Rails specifically.
There was a bug in react-rails 1.6.0 which should be fixed in 1.6.1
Here's the patch:
https://github.com/reactjs/react-rails/pull/478
If the latest version doesn't work for you, please open an issue on the react-rails repo!
I have a Ruby Motion project, and I want to add Interface Builder to it.
I've added the gem:
gem 'ib'
But when I run bundle exec rake ib, I get Don't know how to build task 'ib'
Does any one know what I might be doing wrong? here is my gemfile:
source "https://rubygems.org"
gem "rake"
gem "ProMotion", '~> 2.0'
gem "ProMotion-push", git: 'git#github.com:BananaNeil/ProMotion-push.git', :branch => 'actionable-push-notifications'
gem "cocoapods"
gem "motion-cocoapods"
gem 'xcodeproj'
gem "bubble-wrap-http", git: 'git#github.com:BananaNeil/BubbleWrap-HTTP.git', branch: 'allow_invalid_ssl_certs'
gem "bubble-wrap"
gem "sugarcube" # monkeypatch all the things
gem "motion-yaml"
gem "motion-stump"
gem 'houston'
# Enter debugger with simple syntax
gem 'dbt' #-----> break
# Add pretty print
gem 'motion-pp'
# Handle address book for us
gem 'motion-addressbook'
gem 'ib'
Make sure to require 'ib' inside the Rakefile, either with Bundler or manually for each gem.
And if you use Bundler, you might need to remove the begin/catch guard, because it will silence all import related errors.
I just installed ruby on my windows 7 computer. I installed rails and sqlite3 with the gem. I then made my app work on local BUT I still seem to have problems with sqlite3. When I try this:
rake db:create
the only thing i get is an error:
Please install the sqlite3 adapter: "gem install activerecord-sqlite3-adapter" (sqlite3
is not part of the bundle. Add it to the GemFile).
I've been doing some digging here and there, and I could make this error go away adding this line to my GemFile:
gem "sqlite3", group: :sqlite3
And i got a new error:
no driver for sqlite3 found
I tried the 'bundle' command and I have both sqlite3 and sqlite3-ruby, I reinstalled everything but the problem won't go away. This is my gemFile, I hope it helps:
source 'https://rubygems.org'
gem 'rails', '3.2.12'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
#I tried this too, but nothig changes
#gem 'sqlite3-ruby', :require => 'sqlite3'
gem 'sqlite3-ruby', '1.2.5', :require => 'sqlite3'
gem "sqlite3", group: :sqlite3
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', :platforms => :ruby
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
I really don't know what to do. It's kind of frustrating, it seems like something is not (obviously) properly working with sqlite3, because fixing one error leads to a new error. How can I possibly fix this problem ?
To everybody who's going to have this problem. What I did to fix it was uninstall everything. I though that maybe since I had an updated version of everything, something might not be working properly, maybe some dependencies were wrongly addressed. So I reinstalled everything following this:
Rails Installer Website
Which will make you install everything you need to run your first RoR app. It might not be up to date but it works just fine. Sqlite3 works perfectly now and that was what I needed. I might try to update every single program later, right now I just need something that is actually working. Thanks to everybody else who tried to help.
I am trying to use paperclip without rails(but trying to connect db created by rails).
Using bundler to require gems.
here are my models
class RailsDB < ActiveRecord::Base
establish_connection $db_config[:rails_db]
end
class VoiceCall < RailsDB
belongs_to :campaign
set_table_name :voice_calls
has_attached_file :sound_file
validates_attachment_presence :sound_file
end
If I try to run the program it throws the error
undefined method `has_attached_file
any idea y?
Edit:
my gem file
source "http://rubygems.org"
gem 'activerecord', '< 3.1', :require => 'active_record'
gem 'mysql2', '< 0.3'
gem "paperclip", "~> 2.4"
I require gems using
require "bundler/setup"
Bundler.require(:default)
One more observation. I started irb and required active record and then paperclip. and ran this
p ActiveRecord::Base.methods.select{|m| m =~ /has_attached_file/}
It returns empty list.
but when I open rails console (using "rails c") the statement works and returns the value.( Both are using same gems)
This error means the Paperclip gem is not loaded correctly (or at all) within your application.
Can you post your Gemfile and config/preinitializer.rb?
Is bundler working to successfully load other Gems in your environment?
I've seen this happen when Bundler was not configured correctly for a Rails project causing gems to fail to load. The paperclip model references are the canary in the coal-mine for this larger problem.
had the same issue.
using
gem "paperclip", :git => "git://github.com/thoughtbot/paperclip.git"
instead helped out.
Nokogiri is in my gem file. Bundle install returns the expected output:
Using nokogiri (1.4.4)
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
When trying to execute db:create:all I get the following error:
rake db:create:all
Could not find nokogiri-1.4.4 in any of the sources
If I test in irb, I also get the expected output.
irb(main):003:0> require "rubygems"
=> true
irb(main):004:0> require "nokogiri"
=> true
I have uninstalled and install nokogiri along with its dependencies multiple times.
I'm using:
Rails 3.0.6
Ruby 1.8.7
Any help would be greatly appreciated.
EDIT: 4/25/11 3:02pm EDT
For comment below: Gemfile line for nokogiri is
gem "nokogiri", '1.4.4', :require => "nokogiri"
I made a test with your case in mind.
My Gemfile is like this:
gem "nokogiri", '1.4.4', :require => "nokogiri"
And then rake db:migrate worked just fine
This may be a long shot but you could try:
bundle install --no-deployment
If you are in deployment mode Rails will look for your gems in the vendor directory, rather then the usual install location. It can cause this kind of error.