padrino-gen migration create_indexes is not working - ruby

I am trying to use mongoid_fulltext and can't seem to get the migrations to create the indexes needed. When I try:
padrino-gen migration create_indexes
I get a result
apply orms/mongoid
But when I empty out a document and rebuild it, the new indexes do not show up. Am I doing something wrong?

That isn't the correct way to execute the command. It is something more like padrino rake mongoid:create_indexes. If you generated your project with mongoid as the ORM component, that should work. Run padrino rake -T to see the available tasks.

Related

Add columns to a table managed by Sequel Model

I'm using Sequel::Model. My model has a set_schema block and a create_table call, so the database is completely managed by the model. The database is sqlite.
I'm trying to add columns to the database and I can't find a way to. Adding fields to the schema has no effect. Adding a migration or an alter_table call doesn't do anything. I've asked on IRC and read the docs. I can't find an example of anyone doing this, but it seems simple.
How do I add a column/field to a Sequel Model?
I did a bunch of research and talked to Jeremy Evans. I was going about this wrong. The right way to do this was to remove my schema plugin code and create_table block and move to using migrations. The steps I went through were:
Remove the schema code (create_table, set_schema) from my modesl
Dump the schema from my current sqlite data files into initial migrations into migration files via the sequel -d command
Create a new migration that adds the columns I need via add_column calls in an alter_table block in a change block
Apply the migrations via the sequel -m command
Create rake tasks to run the migrations and hook those tasks into my deploy tasks

Rails table doesn't exist after create model from existing table

I had an existing table named boss_name and I would like to create a rails model for it.
I used "rails generate bossname" to created the model and added the
self.table_name = "boss_name"
inside the class.
After the model had been successfully generated, I tried to start up rails console and trying to query the table.
Bossname.first give me the first value from boss_name table without problem.
rails console worked fine but when I'm running rspec for bossname_spec.rb, I had error which say "Bossname(Table doesn't exist)".
I hope anyone can tell me why it work for rails console and doesn't work for the application. Any hint on how to make it work on the application too is really appreciated.
That indicates that the boss_name table exists in your development database, but not in your test database. You can copy your current development database schema into your test database like this:
rake db:schema:dump
RAILS_ENV=test rake db:setup

How to add migration details to its corresponding model in Rails 4

I remember one of my colleagues did this but I don't remember how. Guess he used some gem or a rake task to achieve this.
Please share if you know how to do this.
Maybe even a gem that can add relevant associations automatically to the model file. This when we do rails g model.
You can use this gem:
https://github.com/ctran/annotate_models
Then run annotate from the terminal. It notes if the field is hstore or array type in case of postgresql. So it is very intelligent. Even myself made a commit to it ;)

Adding an ORM to an existing padrino application

I'm new to ruby, sinatra and padrino,
so it might be a silly question, but:
Is there a way to add an orm to an existing application ?
My problem is that I have created an application with the following command line:
$ padrino-gen project sample_blog -a mysql -b
(I thought that a default ORM was selected.)
Then tried to add a model:
$ padrino-gen model post title:string body:text
<= You need an ORM adapter for run this generator. Sorry!
How can I add the orm without recreatting the whole application?
It's not very important now, since the application do not contains anything,
but I plan latter to add tests, and I would like to know if it's easy.
Thanks for your tips for a beginner.
Open /project-name/.components with your editor and add
:orm: activerecord

db:migrate order in Spree

I'm using spree and created a new payment gateway extension. The problem is, my newly created payment gateway gets created first before the core payment gateway of spree. Here's the error message.
doesn't exist: SHOW FIELDS FROM gateway_options
I've had the same problem. Basically, there's a way to define the order in which extensions are loaded but not when their migrations are ran.
config.extensions = [:all, :site]
More info here.
The way I do it, is simply by renaming the "db" folder of the extensions' migrations needing to be ran later. When the others have ran, I rename it back to its original name and run the migrations again. Dirty, but it works.
There could probably be a way to make a rake task and automate this.

Resources