I install ActiveAdmin to my application. And register the model Order to ActiveAdmin
ActiveAdmin.register Order do
But I get the error uninitialized constant Order; it seems ActiveAdmin not found the model.
My Rails.root is
/home/vagrant/vag/shoppe-subao
the models is in:
/home/vagrant/vag/shoppe-subao/vendor/core/app/models/shoppe$ ls
order.rb
Start the rails server and get following error
=> Rails 4.0.1 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
/vagrant/shoppe-subao/vendor/core/app/models/shoppe/order
Exiting
/vagrant/shoppe-subao/app/admin/order.rb:3:in `<top (required)>': uninitialized constant Order (NameError)
from /home/vagrant/.bundler/ruby/2.2.0/active_admin-82da3c55cb61/lib/active_admin/application.rb:194:in `block in load'
Add require 'activeadmin' to your active_admin.rb initializer
Related
I am trying to add iframe to santized tags by using
config.action_view.sanitized_allowed_tags
I tried to find what tags are already allowed by using the console.
uraai#raiuorial:~/workspace/corse (master) $ heroku run rails c
Running rails c on ⬢ fa4... up, run.9396
Loading production environment (Rails 4.2.6)
irb(main):001:0> puts helper.sanitized_allowed_tags.to_a
NoMethodError: undefined method `sanitized_allowed_tags' for #<ActionView::Base:0x007f18ea91ea60>
from /app/vendor/bundle/ruby/2.3.0/gems/metamagic-3.1.7/lib/metamagic/view_helper.rb:30:in `method_missing'
from (irb):1
from /app/vendor/bundle/ruby/2.3.0/gems/railties-4.2.6/lib/rails/commands/console.rb:110:in `start'
from /app/vendor/bundle/ruby/2.3.0/gems/railties-4.2.6/lib/rails/commands/console.rb:9:in `start'
from /app/vendor/bundle/ruby/2.3.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:68:in `console'
from /app/vendor/bundle/ruby/2.3.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /app/vendor/bundle/ruby/2.3.0/gems/railties-4.2.6/lib/rails/commands.rb:17:in `<top (required)>'
from /app/bin/rails:8:in `require'
from /app/bin/rails:8:in `<main>'
irb(main):002:0>
Any idea how to add it without ignoring the other tags? Thanks
Please have a look on the next example:
module Tapp
class Application < Rails::Application
# In config/application.rb
config.action_view.sanitized_allowed_tags = ['strong', 'em', 'a', 'br', 'iframe']
# ...
end
My app called Tapp, I'm pretty sure you will have another name here ;)
Then in the console:
[retgoat#iMac-Roman ~/workspace/tapp]$ rc
Loading development environment (Rails 4.2.6)
[1] pry(main)> Tapp::Application.config.action_view[:sanitized_allowed_tags]
=> ["strong", "em", "a", "br", "iframe"]
I am trying to upgrade a rails 2 app to rails3 using rails upgrader gem , But starting the server show following error , what could be the possible reason
$bundle exec rails server
/home/user/.rvm/gems/ruby-1.8.7-head/gems/haml-4.0.5/lib/haml/parser.rb:86: warning: regexp has invalid interval
DEPRECATION WARNING: RAILS_ENV is deprecated. Please use ::Rails.env. (called from /home/user/projects/fedena/config/application.rb:5)
=> Booting Mongrel
=> Rails 3.0.9 application starting in development on http://127.0.0.1:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/home/user/.rvm/gems/ruby-1.8.7-head/gems/activesupport-3.0.9/lib/active_support/core_ext/module/introspection.rb:70:in `const_get': uninitialized constant ActionView::ActionViewError (NameError)
from /home/user/.rvm/gems/ruby-1.8.7-head/gems/activesupport-3.0.9/lib/active_support/core_ext/module/introspection.rb:70:in `local_constants'
from /home/user/.rvm/gems/ruby-1.8.7-head/gems/activesupport-3.0.9/lib/active_support/core_ext/module/introspection.rb:70:in `each'
from /home/user/.rvm/gems/ruby-1.8.7-head/gems/activesupport-3.0.9/lib/active_support/core_ext/module/introspection.rb:70:in `local_constants'
from /home/user/.rvm/gems/ruby-1.8.7-head/gems/activesupport-3.0.9/lib/active_support/core_ext/module/introspection.rb:68:in `each'
from /home/user/.rvm/gems/ruby-1.8.7-head/gems/activesupport-3.0.9/lib/active_support/core_ext/module/introspection.rb:68:in `local_constants'
from /home/user/.rvm/gems/ruby-1.8.7-head/gems/activesupport-3.0.9/lib/active_support/core_ext/module/introspection.rb:86:in `local_constant_names'
from /home/user/projects/fedena/config.ru:3
from /home/user/.rvm/gems/ruby-1.8.7-head/gems/rack-1.2.8/lib/rack/builder.rb:46:in `instance_eval'
from /home/user/.rvm/gems/ruby-1.8.7-head/gems/rack-1.2.8/lib/rack/builder.rb:46:in `initialize'
from /home/user/projects/fedena/config.ru:1:in `new'
from /home/user/projects/fedena/config.ru:1
I am trying to start WEBRick for my local developement without any success. Below is the error message that i am getting. Any insight on why it might be failing?
Thanks
C:\Sites\ThinkBlog\crumblr>rails s
=> Booting WEBrick
=> Rails 4.1.4 application starting in development
=> Run `rails server -h` for more startup options
=> Notice: server is listening on all interfaces .
=> Ctrl-C to shutdown server
Exiting
C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/psych.rb:297:in `initialize': Invalid argume`enter code here`nt - ${::Rails.root}/config/facebook.yml (Errno::EINVAL)
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/psych.rb:297:in `open'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/psych.rb:297:in `load_file'
from C:/Sites/ThinkBlog/crumblr/config/initializers/abook.rb:1:in `<top (required)>'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:241:in `load'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:241:in `block in load'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:232:in `load_dependency'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:241:in `load'
You have interpolated your string incorrectly, the interpolation starts with hash sign (#), not dollar.
You need either to change this string to:
FACEBOOK_CONFIG = YAML.load_file("#{::Rails.root}/config/facebook.yml")[::Rails.env]
Or do it without interpolation at all:
sth = YAML.load_file(Rails.root.join 'config', 'facebook.yml')
I enabled Refinery Search and Refinery Blog extensions in Gemfile and run rake db:migrate, rake db:seed.
And per Refinery Search instructions file, added the following to config/application.rb
config.to_prepare do
Refinery.searchable_models = [Refinery::Blog]
end
And also created app/decorators/models/refinery/blog_decorator.rb with
Refinery::Blog.class_eval do
acts_as_indexed :fields => [:title, :body, :custom_teaser]
end
Above example is from: http://refinerycms.com/guides/extending-model
But when I try to run rails c or rails s, there is an error:
=> Ctrl-C to shutdown server
Exiting
/home/bismailov/Desktop/my_docs/Inbox/ror/maqolarefinery/app/decorators/models/refinery/blog_decorator.rb:2:in `block in <top (required)>':
undefined method `acts_as_indexed' for Refinery::Blog:Module (NoMethodError)
from /home/bismailov/Desktop/my_docs/Inbox/ror/maqolarefinery/app/decorators/models/refinery/blog_decorator.rb:1:in `class_eval'
What could I be missing here? Thank you a lot!
Actually Refinery::Blog is a module not a model. Ideally you should use Refinery::Blog::Post.
After I install the custom-err-msg plugin, I get an error when I try to run rails server:
$ rails server
=> Booting WEBrick
=> Rails 3.0.3 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/home/jason/rails/snip/vendor/plugins/custom-err-msg/init.rb:3: uninitialized constant ActiveRecord::Errors (NameError)
from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/plugin.rb:81
from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:25:in `instance_exec'
from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:25:in `run'
from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:50:in `run_initializers'
from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:49:in `each'
from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:49:in `run_initializers'
from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/application.rb:134:in `initialize!'
from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/application.rb:77:in `send'
from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/application.rb:77:in `method_missing'
from /home/jason/rails/snip/config/environment.rb:5
from /home/jason/rails/snip/config.ru:3:in `require'
from /home/jason/rails/snip/config.ru:3
from /usr/lib/ruby/gems/1.8/gems/rack-1.2.1/lib/rack/builder.rb:46:in `instance_eval'
from /usr/lib/ruby/gems/1.8/gems/rack-1.2.1/lib/rack/builder.rb:46:in `initialize'
from /home/jason/rails/snip/config.ru:1:in `new'
from /home/jason/rails/snip/config.ru:1
Any idea why this is happening?
Here's an updated version that will work with Rails 3.
https://github.com/seansawyer/custom-err-msg
To fix the undefined method keys for nil:NilClass error, a method in lib/custom_error_message.rb needs to be changed to this:
def starts_with_humanized_column_followed_by_circumflex?(message)
keys.any? do |column|
humanized = #base.class.human_attribute_name column.to_s.split('.').last.to_s
message.match(/^#{humanized} \^/)
end
end
Someone, please send him a pull request!
This plugin is not compatible with Rails 3. I would recommend finding a fork that is or forking it and updating yourself.