First time using rails 5, trouble with tsort_each - ruby-on-rails

it's my first time using Rails 5. I'm trying to run; rails s and it's giving me this:
$ rails s
=> Booting Puma
=> Rails 5.0.0.beta2 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
DEPRECATION WARNING: before_filter is deprecated and will be removed in Rails 5.1. Use before_action instead. (called from block in tsort_each at /Users/ericcarpentier/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/tsort.rb:226)
DEPRECATION WARNING: after_filter is deprecated and will be removed in Rails 5.1. Use after_action instead. (called from block in tsort_each at /Users/ericcarpentier/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/tsort.rb:226)
DEPRECATION WARNING: alias_method_chain is deprecated. Please, use Module#prepend instead. From module, you can access the original method using super. (called from block in tsort_each at /Users/ericcarpentier/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/tsort.rb:226)
DEPRECATION WARNING: alias_method_chain is deprecated. Please, use Module#prepend instead. From module, you can access the original method using super. (called from block in tsort_each at /Users/ericcarpentier/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/tsort.rb:226)
Exiting
/Users/ericcarpentier/.rvm/gems/ruby-2.2.2/gems/activesupport-5.0.0.beta2/lib/active_support/logger_silence.rb:23:in `level': undefined method `[]' for nil:NilClass (NoMethodError)
from /Users/ericcarpentier/.rvm/gems/ruby-2.2.2/gems/railties-5.0.0.beta2/lib/rails/commands/server.rb:140:in `log_to_stdout'
from /Users/ericcarpentier/.rvm/gems/ruby-2.2.2/gems/railties-5.0.0.beta2/lib/rails/commands/server.rb:76:in `start'
from /Users/ericcarpentier/.rvm/gems/ruby-2.2.2/gems/railties-5.0.0.beta2/lib/rails/commands/commands_tasks.rb:90:in `block in server'
from /Users/ericcarpentier/.rvm/gems/ruby-2.2.2/gems/railties-5.0.0.beta2/lib/rails/commands/commands_tasks.rb:85:in `tap'
from /Users/ericcarpentier/.rvm/gems/ruby-2.2.2/gems/railties-5.0.0.beta2/lib/rails/commands/commands_tasks.rb:85:in `server'
from /Users/ericcarpentier/.rvm/gems/ruby-2.2.2/gems/railties-5.0.0.beta2/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
from /Users/ericcarpentier/.rvm/gems/ruby-2.2.2/gems/railties-5.0.0.beta2/lib/rails/command.rb:20:in /`run'
from /Users/ericcarpentier/.rvm/gems/ruby-2.2.2/gems/railties-5.0.0.beta2/lib/rails/commands.rb:19:in `<top (required)>'
from bin/rails:9:in `require'
from bin/rails:9:in `<main>'

In my Gemfile , I have:
gem 'rails_12factor'
and I am getting the same bug
I changed Gemfile to this:
group :production, :staging do
gem 'rails_12factor'
end
bundle install and it works now. Try it

Related

How to add iframe to sanitized tags in ruby on rails 4.2.6?

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"]

Error while upgrading rails 2 to 3 `const_get': uninitialized constant ActionView::ActionViewError (NameError)

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

Difficulties with Ruby version for Rails and activesupport-3.2.12

I have a rails application which works built on my test environment.
ruby -v => 1.9.3p194
rails -v => 3.2.12
gem -v => 1.8.23
On the server I wish to deploy to, the outputs are the following:
ruby -v => 1.9.3p0
rails -v => 3.2.12
gem -v => 1.8.15
I've started with a fresh installation of the server but I cannot get the server version of ruby and gem to match.
Additionally when I run rails s on the server (just to test) this is the failed output:
rails s
=> Booting WEBrick
=> Rails 3.2.12 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/var/lib/gems/1.8/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:245:in `load': /var/www/New/confed ':', expecting kEND (SyntaxError)
match '/about', to: 'static_pages#about'
^
/var/www/New/config/routes.rb:6: syntax error, unexpected ':', expecting kEND
match '/cv', to: 'static_pages#cv'
^
from /var/lib/gems/1.8/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:245:in `load'
from /var/lib/gems/1.8/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:236:in `load_dependency'
from /var/lib/gems/1.8/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:245:in `load'
from /var/lib/gems/1.8/gems/railties-3.2.12/lib/rails/application/routes_reloader.rb:40:in `load_paths'
from /var/lib/gems/1.8/gems/railties-3.2.12/lib/rails/application/routes_reloader.rb:40:in `each'
from /var/lib/gems/1.8/gems/railties-3.2.12/lib/rails/application/routes_reloader.rb:40:in `load_paths'
from /var/lib/gems/1.8/gems/railties-3.2.12/lib/rails/application/routes_reloader.rb:16:in `reload!'
from /var/lib/gems/1.8/gems/railties-3.2.12/lib/rails/application/routes_reloader.rb:26:in `updater'
from /var/lib/gems/1.8/gems/activesupport-3.2.12/lib/active_support/file_update_checker.rb:78:in `call'
from /var/lib/gems/1.8/gems/activesupport-3.2.12/lib/active_support/file_update_checker.rb:78:in `execute'
from /var/lib/gems/1.8/gems/railties-3.2.12/lib/rails/application/routes_reloader.rb:27:in `updater'
from /var/lib/gems/1.8/gems/railties-3.2.12/lib/rails/application/routes_reloader.rb:7:in `execute_if_updated'
from /var/lib/gems/1.8/gems/railties-3.2.12/lib/rails/application/finisher.rb:66
from /var/lib/gems/1.8/gems/railties-3.2.12/lib/rails/initializable.rb:30:in `instance_exec'
from /var/lib/gems/1.8/gems/railties-3.2.12/lib/rails/initializable.rb:30:in `run'
from /var/lib/gems/1.8/gems/railties-3.2.12/lib/rails/initializable.rb:55:in `run_initializers'
from /var/lib/gems/1.8/gems/railties-3.2.12/lib/rails/initializable.rb:54:in `each'
from /var/lib/gems/1.8/gems/railties-3.2.12/lib/rails/initializable.rb:54:in `run_initializers'
from /var/lib/gems/1.8/gems/railties-3.2.12/lib/rails/application.rb:136:in `initialize!'
from /var/lib/gems/1.8/gems/railties-3.2.12/lib/rails/railtie/configurable.rb:30:in `send'
from /var/lib/gems/1.8/gems/railties-3.2.12/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /var/www/New/config/environment.rb:5
from /var/www/New/config.ru:3:in `require'
from /var/www/New/config.ru:3
from /var/lib/gems/1.8/gems/rack-1.4.5/lib/rack/builder.rb:51:in `instance_eval'
from /var/lib/gems/1.8/gems/rack-1.4.5/lib/rack/builder.rb:51:in `initialize'
from /var/www/New/config.ru:0:in `new'
from /var/www/New/config.ru:0
I've looked on my test system and I don't have /var/lib/gems/1.8 I only have /var/lib/gems/1.9.1
From your stack trace, it actually looks like you're running against Ruby 1.8, which doesn't support the simplified hash syntax symbol: value whereas 1.8 only had :symbol => value.
You can use rvm or rbenv to manage multiple ruby versions. rbenv imo is the better of the two when working with Rails.
Answering Ryan's question of why I think rbenv > rvm is based on personal feelings. I've found rbenv easy to work with, easy to understand and conceptualize how it was working, and I haven't run into a scenario where it has failed me. Additionally the source code is quite readable, which made my one foray for configuration easy to do.

Rails application not starting

I have a new application that is giving me errors when I do
rails server
Here is the error:
/home/agenadinik/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.7/lib/rails/script_rails_loader.rb:11: warning: Insecure world writable dir /home/agenadinik in PATH, mode 040777
/home/agenadinik/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.12/lib/bundler/runtime.rb:136: warning: Insecure world writable dir /home/agenadinik in PATH, mode 040777
=> Booting WEBrick
=> Rails 3.0.7 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/home/agenadinik/.rvm/gems/ruby-1.9.2-p180/gems/rack-1.2.2/lib/rack/builder.rb:35:in `eval': /home/agenadinik/workspace/udfr/config.ru:6: syntax error, unexpected keyword_end, expecting ')' (SyntaxError)
from /home/agenadinik/.rvm/gems/ruby-1.9.2-p180/gems/rack-1.2.2/lib/rack/builder.rb:35:in `parse_file'
from /home/agenadinik/.rvm/gems/ruby-1.9.2-p180/gems/rack-1.2.2/lib/rack/server.rb:162:in `app'
from /home/agenadinik/.rvm/gems/ruby-1.9.2-p180/gems/rack-1.2.2/lib/rack/server.rb:248:in `wrapped_app'
from /home/agenadinik/.rvm/gems/ruby-1.9.2-p180/gems/rack-1.2.2/lib/rack/server.rb:213:in `start'
from /home/agenadinik/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.7/lib/rails/commands/server.rb:65:in `start'
from /home/agenadinik/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.7/lib/rails/commands.rb:30:in `block in <top (required)>'
from /home/agenadinik/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.7/lib/rails/commands.rb:27:in `tap'
from /home/agenadinik/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.7/lib/rails/commands.rb:27:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
It seems to be complaining about my config.ru file. Here it is:
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
run Udfr::Application
Here is my environment.rb file:
# Load the rails application
require File.join(File.dirname(__FILE__), 'boot')
require File.expand_path('../application', __FILE__)
if RUBY_PLATFORM =~ /java/
require 'rubygems'
RAILS_CONNECTION_ADAPTERS = %w(jdbc)
end
# Initialize the rails application
Rails::Initializer.run do |config|
Udfr::Application.initialize!
I changed that file according to these instructions:
http://www.digitalsanctum.com/2007/07/24/jruby-deploying-a-rails-application-on-tomcat/
Any idea what the problem is?
The instructions you followed are for Rails 2 and will not work with your Rails 3 app.
The updated instructions for getting Ruby on Rails to work on jruby are to edit your gemfile and place your gem requirements there.
In Gemfile:
if defined?(JRUBY_VERSION)
gem 'activerecord-jdbc-adapter'
end
Then run bundle.

Can't run rails server after installing custom-err-msg

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.

Resources