In previous apps when the same database data has been required by everyone we've used seed_dumper & rake db:seed:dump to populate the seeds file and then rake db:seed.
For this app, using the Comfortable Mexican Sofa CMS gem and the fortress plugin it would be nice to do the same. Only seed_dumper only dumps the users - nothing else.
seed_dump (the 'parent' gem) gives the following error:
rake aborted!
NameError: undefined local variable or method `cms_manageable' for Comfy::Cms::Page(Table doesn't exist):Class
/usr/local/rvm/gems/ruby-2.0.0-p247#global/gems/activerecord-4.0.0/lib/active_record/dynamic_matchers.rb:22:in `method_missing'
/path to my app/app/models/comfy/cms/page.rb:9:in `<class:Page>'
Any ideas or alternate methods would be appreciated. Cheers.
Now using only gem 'seed_dump' (not seed_dumper), running the command bundle exec rake db:seed:dump works for exporting seed data.
Related
I have some simple Rails 5 API models, e.g. class Training. Executing
Training.delete_all
works like expected from Rails console.
The exact same line of code results in
in `<main>': uninitialized constant Training (NameError)
when used (as first line) in seeds.rb.
I cannot guess why.
As established in the comments, using bundle exec ruby db/seeds.rb won't work as it won't prepare the environment (load all the models, etc.).
Proper way of running Rails seeds is by bundle exec rails db:seed.
ruby 2.1.5, rails 4.2, rake
installed gem "seedbank"
seedbank (0.3.0)
I have following structure:
seeds/shop/curtain/
I want run all seed files from folder curtain
rake db:seed:shop:curtain
rake aborted!
Don't know how to build task 'db:seed:shop:curtain'
What wrong, explain me please. Thank you
I have following structure: seed/shop/curtain/
As per seedbank documentation the structure should be
db/seeds/shop/curtain.seeds.rb
So you need to rename seed to seeds
and add curtain.seeds.rb inside shop folder so you will get
rake db:seed:shop:curtain
EDIT
Not sure if seedbank supports 2-3 level of hierarchy so move the curtain folder directly inside seeds and try
rake db:seed:curtain
This will load the seed data from
db/seeds.rb
db/seeds/*.seeds.rb
db/seeds/curtain/*.seeds.rb
I have stated working on neo4j with rails using the gem 'neo4j', I want to seed some data in neo4j database. But whenever I am trying to do rake db:seed, it says
rake aborted!
Don't know how to build task 'db:seed'
I have checked all the rake tasks using rake -T, and there is no rake db:seed.
Does any one have any idea?
The Neo4j gem doesn't have a seed command. The command you're trying to use is provided by ActiveRecord. We'd love to add this functionality in, though, and if you'd like to help, we'd gladly accept a PR and/or contribute to the process. For now, open up an issue at https://github.com/neo4jrb/neo4j/issues and we can add it to the roadmap.
Finally got the solutions.
Create a file seed.rake under lib/tasks and put the code
namespace :db do
desc 'Load the seed data from db/seeds.rb'
task :seed => :environment do
seed_file = File.join(Rails.root, 'db', 'seeds.rb')
load(seed_file) if File.exist?(seed_file)
end
end
Check apps root directory, is there a Rakefile?
Make a file with name "Rakefile" and enter these line
"#!/usr/bin/env rake
require File.expand_path('../config/application', FILE)
APP_NAME::Application.load_tasks
As others mentioned before, rails db:seed is a built-in feature backed by ActiveRecord. Assuming you are using neo4jrb without ActiveRecord, you won't be able to use this command to seed database any more.
However, you can use seedbank gem to recover this ability.
It does not depend on ActiveRecord like seed_fu and other seeding gems do. So it will work just fine with neo4jrb.
The process is rather simple.
put seedbank in your Gemfile and bundle install.
create directory db/seeds/
create a seeds file under the db/seeds/ directory
for example
#db/seeds/show.seeds.rb
Show.create(name: "Better Call Saul", producer: "Vince Gilligan")
run rake db:seed:show
Hey people i know maybe 1% of ruby and need many help...
I migrated a system from one server to another server
When I try to insert an entry to the database using the system, I get the following error (remembering that I use ruby is 2.1):
undefined method `insert_record' for #<Array:0x007fec2a2b2fa0>
i know maybe this is a solution:
http://alok-anand-ror.blogspot.com.br/2013/11/undefined-method-insertrecord-for.html
i have gems of rake instaled 0.9.2 and 0.9.2.2
when i try run "rake db:migrate" (I think it would solve, I do not know) i received
rake aborted No rake file found
if somebody can help me I greatly appreciate.
thanks in advanced.
it seems your Rakefile is missing .
Check your rails folder should contain Rakefile with following content
#!/usr/bin/env rake
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__)
Demo::Application.load_tasks
~
and
undefined method `insert_record' for #<Array:0x007fec2a2b2fa0>
this error is because of incompatibility issues with rails and ruby , try upgrading rails
I have a rails app that requires multi-table inheritance for which I am using the CITIER gem which itself requires the rails_sql_views gem to produce database views representing objects.
So far, so good. All this works like a charm on my local machine using sqlite3. When I try to deploy the application to Heroku, however, I am neither able to perform a database migration nor able to access the rails console.
The reason seems to be that the rails_sql_views gem tries to access some methods of PostgreSQLAdapter which are claimed to be non-existent. However, when I check the files of the rails repository, I can find these methods in the code. What is going on here?
When I try to run "heroku run rake db:migrate", I'll end up with the following error trace:
Running rake db:migrate --trace attached to terminal... up, run.1 rake aborted!
undefined method `tables' for class `ActiveRecord::ConnectionAdapters::PostgreSQLAdapter'
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/core_ext/module/aliasing.rb:31:in `alias_method'
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/core_ext/module/aliasing.rb:31:in `alias_method_chain'
/app/vendor/bundle/ruby/1.9.1/gems/rails_sql_views-0.8.0/lib/rails_sql_views/connection_adapters/postgresql_adapter.rb:5:in `included'
/app/vendor/bundle/ruby/1.9.1/gems/rails_sql_views-0.8.0/lib/rails_sql_views/loader.rb:12:in `include'
[....]
This looks like an incompatibility between sqlite3 and postgres adapters with that gem. You should try to keep development as close to production as possible. Try installing postgress locally https://devcenter.heroku.com/articles/local-postgresql and see if you get the same error locally. If you do, consider writing a detailed bug report and sending it to the author of the Gem, or attempt to fix it yourself and send a pull request.