I'm trying to create a simple application with ruby in rails. I've created this scaffold:
rails generate scaffold Pic title:string content:blob description:text
and when I try to migrate db with rake db:migrate
I'm getting this error:
rake aborted!
An error has occurred, this and all later migrations canceled:
undefined method `blob' for #<ActiveRecord::ConnectionAdapters::TableDefinition:0xb74f8ec4>
When I write say text
instead of blob
it works normally. So what's the problem with blob
?
A Rails migration is a tool for changing an application's database schema. Instead of managing SQL scripts, you define database changes in a domain-specific language (DSL). The code is database-independent, so you can easily move your app to a new platform.
Go to db/migrate subdirectory of your application and edit each file one by one using any simple text editor. The ID column will be created automatically, so don't do it here as well. The method self. up is used when migrating to a new version, self.
By default, the generated migration will include t. timestamps (which creates the updated_at and created_at columns that are automatically populated by Active Record).
You must rollback the migration (for example with bin/rails db:rollback ), edit your migration, and then run bin/rails db:migrate to run the corrected version.
The keyword is binary, not blob.
rails generate scaffold Pic title:string content:binary description:text
There is no keyword blob in rails, you need binary.
rails generate scaffold Pic title:string content:binary description:text
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With