ActiveAdmin.register ColorGroup do
index :download_links => [:csv] do
selectable_column
column(:id) { |it| auto_link it, it.id }
column(:name) { |it| auto_link it, it.name }
column(:slug) { |it| auto_link it, it.slug }
column(:family) { |it| auto_link it.color_family, it.color_family.name if it.color_family.present? }
column :asset_url
column :order
column :image do |it|
if it.nil?
"N/A"
else
# Use image_tag here...
link_to sanitize("<img src=\"#{it.asset_url}\" class=\"cgs-img\" width=\"101\" height=\"24\" />"), it.asset_url
end
end
actions
end
end
Showing posts with label Rails. Show all posts
Showing posts with label Rails. Show all posts
Friday, October 24, 2014
Images in Active Admin Index pages.
An example of how images can be embedded in Active Admin index pages in a Ruby on Rails application:
Labels:
Rails,
Ruby,
Ruby on Rails
Location:
San Francisco, CA, USA
Friday, March 26, 2010
Nondiscriptive Rail Error "Errors running test:units!"
Errors Running test:units!
The "Errors running test:units!" error while creating a brand new Rails application under Cygwin:
rails world_app -d mysql cd world_app $ rake test
This results in the following error message:
(in /cygdrive/d/workspace/tt/world_app) /usr/bin/ruby.exe -I"lib:test" "/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb" /usr/bin/ruby.exe -I"lib:test" "/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb" Errors running test:units!
Attempting to execute the Rails tests results in the same eror:
$ rake test --trace (in /cygdrive/d/workspace/tt/world_app) ** Invoke test (first_time) ** Execute test ** Invoke test:units (first_time) ** Invoke db:test:prepare (first_time) ** Invoke db:abort_if_pending_migrations (first_time) ** Invoke environment (first_time) ** Execute environment ** Execute db:abort_if_pending_migrations ** Invoke test:functionals (first_time) ** Invoke db:test:prepare ** Execute test:functionals /usr/bin/ruby.exe -I"lib:test" "/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb" ** Invoke test:integration (first_time) ** Invoke db:test:prepare ** Execute test:integration /usr/bin/ruby.exe -I"lib:test" "/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb" Errors running test:units!
Fixing the Error
The following steps fixed the error:
- Edit config/database.yml
- Make sure the db password is correct.
- Make sure the db is created.
- Change "host: localhost" to "host: 127.0.0.1" if need be.
$ rake test --trace (in /cygdrive/d/workspace/tt/world_app) ** Invoke test (first_time) ** Execute test ** Invoke test:units (first_time) ** Invoke db:test:prepare (first_time) ** Invoke db:abort_if_pending_migrations (first_time) ** Invoke environment (first_time) ** Execute environment ** Execute db:abort_if_pending_migrations ** Execute db:test:prepare ** Invoke db:test:load (first_time) ** Invoke db:test:purge (first_time) ** Invoke environment ** Execute db:test:purge ** Execute db:test:load ** Invoke db:schema:load (first_time) ** Invoke environment ** Execute db:schema:load ** Execute test:units /usr/bin/ruby.exe -I"lib:test" "/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb" ** Invoke test:functionals (first_time) ** Invoke db:test:prepare ** Execute test:functionals /usr/bin/ruby.exe -I"lib:test" "/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb" ** Invoke test:integration (first_time) ** Invoke db:test:prepare ** Execute test:integration /usr/bin/ruby.exe -I"lib:test" "/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb"
Thursday, October 15, 2009
Rails Error: "interning empty string"
The "interning empty string" error kept popping up in some of our code written prior to upgrading to Ruby on Rails 2.3.4.
The culprit turned out to be:
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/attribute_methods.rb:344:in `respond_to?' C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/attribute_methods.rb:344:in `respond_to?' C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/validations.rb:40:in `value' C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/validations.rb:79:in `generate_message' C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/validations.rb:30:in `message' C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/validations.rb:34:in `full_message' C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/validations.rb:275:in `full_messages' C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/validations.rb:275:in `map' C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/validations.rb:275:in `full_messages' C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/base.rb:2036:in `inject' C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/validations.rb:274:in `each' C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/validations.rb:274:in `inject' C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/validations.rb:274:in `full_messages' C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_view/helpers/active_record_helper.rb:201:in `error_messages_for' C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/core_ext/enumerable.rb:59:in `map' C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/core_ext/enumerable.rb:59:in `sum' C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_view/helpers/active_record_helper.rb:201:in `error_messages_for' C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/core_ext/object/misc.rb:78:in `with_options' C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_view/helpers/active_record_helper.rb:192:in `error_messages_for' C:/workspace/epanel_latest1/app/helpers/application_helper.rb:184:in `error_messages_for' C:/workspace/epanel_latest1/app/views/login_users/login.html.erb:60:in `_run_erb_app47views47login_users47login46html46erb'
The culprit turned out to be:
model.errors.add('', 'Some message')
and the fix was to change this tomodel.errors.add_to_base('Some message')
Wednesday, October 7, 2009
Rails: undefined method `use_transactional_fixtures=' in Rails 2.3
Problem: You try to run your Rails tests under Rails 2.3 and you run across the "undefined method `use_transactional_fixtures='" error.
Fix:
Change the class definition in test_helper.rb from
./test/integration/../test_helper.rb:29: undefined method `use_transactional_fixtures=' for Test::Unit::TestCase:Class (NoMethodError)
from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from ./test/integration/survey_user_interface_test.rb:1
from /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5:in `load'
from /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5
from /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5:in `each'
from /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5
rake aborted!
Command failed with status (1): [/usr/bin/ruby.exe -I"lib:test" "/usr/lib/r...]
Fix:
Change the class definition in test_helper.rb from
class Test::Unit::TestCaseto
class ActiveSupport::TestCase
Wednesday, September 2, 2009
MySQL Error: Can't connect to local MySQL server through socket
You try to run your Rails project and keep getting the "Can't connect to local MySQL server through socket" MySQL Error.
The quickest way to fix this issue is to edit the database.yml file and replace localhost with 127.0.0.1.
Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/mysql_adapter.rb:548:in `real_connect' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/mysql_adapter.rb:548:in `connect' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/mysql_adapter.rb:198:in `initialize' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/mysql_adapter.rb:74:in `new' /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/mysql_adapter.rb:74:in `mysql_connection'
The quickest way to fix this issue is to edit the database.yml file and replace localhost with 127.0.0.1.
Subscribe to:
Posts (Atom)