Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

README Instructions for Rails 3 #2

Open
flickerfly opened this issue Dec 22, 2011 · 5 comments
Open

README Instructions for Rails 3 #2

flickerfly opened this issue Dec 22, 2011 · 5 comments

Comments

@flickerfly
Copy link

Forgive me for my newbness.

I'm trying to use your OFAC gem (v 1.2.3) in rails 3. The README tells me to do scripts/generate ofac_migration which I've determined changed in rails 3 to something like rails generate ofac_migration. When I tried that rails reported "Could not find generator ofac_migration."

Is it possible to use this gem in rails 3? If you can toss me some quick commands I'll be glad to format that into a pull request for inclusion in the readme.

Thank you!

@flickerfly
Copy link
Author

Here are some notes on getting it working enough to do the rake ofac:update_data successfully. Hopefully that'll be helpful to someone in the mean time.

sudo gem install ofac
sudo gem install mysql (on ubuntu/debian install libmysqlclient-dev first)
setup a basic rails environment
vim Gemfile and add
gem 'ofac'
gem 'mysql'

generate database...
rails generate model ofac_sdns name:text sdn_type:string program:string title:string vessel_call_sign:string vessel_type:string vessel_tonnage:string gross_registered_tonnage:string vessel_flag:string vessel_owner:string remarks:text address:text city:string country:string address_remarks:string alternate_identity_type:string alternate_identity_name:text alternate_identity_remarks:string

vim db/migrate/sometimestamp_create_ofac_sdns.rb and add this line between the first and second of the three lines containing "end" at the bottom of the file.
add_index :ofac_sdns, :sdn_type

rake db:migrate VERSION=sametimestap

rake ofac:update_data

@kevintyll
Copy link
Owner

The gem itself works in rails 3, as we just recently upgraded ourselves and we're still using the gem just fine. Unfortunately, it looks like the generator probably does not work. You are getting the "could not find..." error because rails 3 looks for generators in lib/generators. My generators dir is not in the lib dir.

However, I suspect the problems are more than just the location of the files. Generators got a big overhaul in rails 3 using thor now. I believe even the generator base class namespace has changed.

If you wanted to try your hand at upgrading it, that would be super, I be very appreciative. But if you just want to run the migration and be done, then it's simple enough to do it manually. Just create a migration and copy the contents of generators/ofac_migration/templates/migration.rb into it.

Good luck. I hope you find the gem useful.

Kevin Tyll
[email protected]

On Dec 22, 2011, at 10:03 AM, Josiah Ritchie wrote:

Forgive me for my newbness.

I'm trying to use your OFAC gem (v 1.2.3) in rails 3. The README tells me to do scripts/generate ofac_migration which I've determined changed in rails 3 to something like rails generate ofac_migration. When I tried that rails reported "Could not find generator ofac_migration."

Is it possible to use this gem in rails 3? If you can toss me some quick commands I'll be glad to format that into a pull request for inclusion in the readme.

Thank you!


Reply to this email directly or view it on GitHub:
#2

@flickerfly
Copy link
Author

Great, I'll poke at it and see if I can't add something to the project.

@hayd
Copy link

hayd commented Apr 18, 2014

I saw the following error

File conversion ran for 0.0226355272 minutes.
Deleting all records in ofac_sdn...
Importing into Mysql...
rake aborted!
ActiveRecord::StatementInvalid: Mysql::Error: The used command is not allowed with this MySQL version:     LOAD DATA LOCAL INFILE '/tmp/ofac20140417-3814-1xikzyz' REPLACE INTO TABLE ofac_sdns FIELDS TERMINATED BY '|' ENCLOSED BY "`" LINES TERMINATED BY '

I couldn't seem to get this workaround working, but atm it looks like you need to reconfigure (recent versions of) mysql before this is allowed. http://stackoverflow.com/questions/18437689/error-1148-the-used-command-is-not-allowed-with-this-mysql-version ?

@kevintyll
Copy link
Owner

I was never aware of that server variable. Looking at the mysql manual, it looks like the default is still to have it enabled up to version 5.7. I'm not sure rails can set the variable when establishing a connection. It may not work unless it's enabled on the DB itself.

A down and dirty solution would be to rescue that error in the bulk_mysql_update method and call active_record_file_load. Feel free to submit a pull request if you find a solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants