I used rvm upgrading to 1.9.2-p180. during the installation, libyaml 0.1.3 was fetched and installed.
Now when I have my database.yml in a rails project like this:
defaults: &defaults
adapter: mysql
encoding: UTF-8
username: root
password:
host: localhost
engine: InnoDB
test:
<<: *defaults
database: my_app_test
in console,
YAML.load_file("config/database.yml")
The result is:
{"test" => {"apapter" => "mysql"...}}
The problem is the "database" key is missing. it seems not to merge the defaults node and test node togther, rather it just copy the default node.
any idea?
Anyway, upgrade to ruby-p290 solved the issue.
If I understand you correctly, I can't duplicate that, also using 1.9.2.180:
irb(main):002:0> YAML::load_file('./test.yml')
=> {"defaults"=>{"adapter"=>"mysql", "encoding"=>"UTF-8", "username"=>"root", "password"=>nil, "host"=>"localhost", "engine"=>"InnoDB"}, "test"=>{"adapter"=>"mysql", "encoding"=>"UTF-8", "username"=>"root", "password"=>nil, "host"=>"localhost", "engine"=>"InnoDB", "database"=>"my_app_test"}}
(Scroll right to see: "database"=>"my_app_test"}} )
Not sure if this is an answer as such, but I couldn't put the code in a comment. If I have the wrong end of the stick I'll edit or delete...
Related
I deployed a rails 5 app to heroku. I used mailgun for sending emails and it works well in development. In production when I try to sign up a user, I get this error:
production.rb:
config.action_mailer.delivery_method = :mailgun
config.action_mailer.default_url_options = { :host => 'http://myappname.herokuapp.com', :protocol => 'https'}
config.action_mailer.mailgun_settings = {
domain: ENV['MAILGUN_DOMAIN'],
api_key: ENV['MAILGUN_KEY']
}
The MAILGUN_DOMAIN and MAILGUN_KEY were stored as environment variables in my PC. Is there something I did not do right? Thanks!
After installing figaro gem:
application.yml
development:
MAILGUN_DOMAIN: ******************************
MAILGUN_KEY: **************************
production:
MAILGUN_DOMAIN: ******************************
MAILGUN_KEY: **************************
I still get the same error!!
It looks like it is related to the version of the mail gem that is installed as per this issue on mailgunner.
The workaround suggested there is to explicitly add the mail gem to your Gemfile and to lock the version to 2.6.5.
gem 'mail', '2.6.5'
You'll then need to run bundle update mail --conservative to get the new version.
I'm upgrading a Sinatra ("classic" style) app to latest released version, from 1.3.3 to 1.4.6. I also use config_file from sinatra-contrib (also upgraded from 1.3.2 to 1.4.6) with multi-environments.
My config file (config/app.yml) looks like:
development: &defaults
console_username: admin
console_password: secret
test:
<<: *defaults
staging:
<<: *defaults
production:
<<: *defaults
On the other hand, I have some POROs under lib/. Before the upgrade, I can access to the settings inside those classes under lib/, but now I can't. In summary, previously I can do something like:
settings.console_username
After the upgrade, I need to access these variables by:
Sinatra::Application.console_username
I reviewed the changelog but I can't find this change documented, am I missing something?
PS: I also found this: Access Sinatra settings from a model. I'm agree with the last answer, probably is a better idea to decouple this thing, and pass the settings to the class.
config/database.yml
default: &default
adapter: sqlite3
encoding: unicode
development:
<<: *default
database: development.sqlite3
username: admin
password: wsxqaz
server: localhost
# port:
ruby code:
require "yaml"
require "active_record"
# shorten lines with this namespace
include ActiveRecord::Tasks
# trying to use db folder
DatabaseTasks.db_dir = './db'
db_config_file = "./config/database.yml"
db_config = YAML.load_file(db_config_file)
db_type = db_config['development']
#sldbtask = SQLiteDatabaseTasks.new(db_type, root = './')
#sldbtask.create
I've tried changing the root argument but that doesn't make any difference either.
What do I need to get my db file into the db directory? It creates it okay and the table stuff is pending. First things first.
I believe that the database is supposed to be generated in the root directory. The db folder is used for activerecord's schema and migration files. Why is it so important that the database generates in the db directory?
EDIT
I just found an easier way to do this. After you require all of the files you want, then enter set :database, {database:"./db/myDatabase.db"}. If you already have the line set :database in your code, just add that to it. Good luck!
I downloaded the postgres.app for my Mac OSX machine. I have a rails app that has connected and used the postgres DB that came with the postgres app.
Now I am writing a pure Ruby test script (Not Rails, pure Ruby, not even Active Record) to try to connect to the postgres database instance. These are the steps I followed to set this up
1) ran this command on the terminal:
gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/MacOS/bin/pg_config
2) Added this code to the test script:
#!/usr/bin/env ruby
#encoding: utf-8
require "pg"
#conn = PG.connect(
:dbname => 'oData',
:user => 'am',
:password => '')
#conn.exec("CREATE TABLE programs (id serial NOT NULL, name character varying(255);");
I got this from this link
When I ran this script I get the following error:
/Users/am/.rvm/gems/ruby-2.0.0-p247/gems/pg-0.16.0/lib/pg.rb:38:in `initialize': could
not connect to server: No such file or directory (PG::ConnectionBad)
Is the server running locally and accepting
connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?
My Debug efforts:
My postgres.app is up and running.
I looked at the pg gem [documentation][2] and my syntax seemed OK.
The location of my postgres DB is entered in my bash script like so
PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH"
Not sure what to do next. Any help would be appreciated, Thanks.
are you sure postgres is listening on a socket? are you sure the username and password is right?
I would be inclined to try something like
require 'pg'
puts PG::Connection.ping(:dbname => 'oData',:user => 'am',:password => '')
puts "trying with tcp"
puts PG::Connection.ping(:dbname => 'oData',:user => 'am',:password => '', :port => 5432)
I used active record gem to make the connection work and it was fine
Settings to connect works for me.
But that code should look like
#conn.exec("CREATE TABLE programs (id serial NOT NULL, name
character(255))")
Any help getting the gem working would be appreciated. I'm down to configuration issues (i think) and there isn't a lot of documentation to help me get running.
So I have the parallel_tests gem in my project. I believe I have two problems, one that cannot be seen without the other.
The first problem is that I don't think I have my database.yml file setup correctly. #1 we call it servers.yml (not sure if there is an importance with the name), and 2 we didn't have a "test" section setup. The example shows
test:
database: yourproject_test<%= ENV['TEST_ENV_NUMBER'] %>
our server.yml file contains the following:
db1:
adapter: jdbc
driver: oracle.jdbc.driver.OracleDriver
url: url_to_db1
username: uname
password: pass
db2:
adapter: jdbc
driver: oracle.jdbc.driver.OracleDriver
url: url_to_db2
username: uname
password: pass
db3:
adapter: jdbc
driver: oracle.jdbc.driver.OracleDriver
url: url_to_db3
username: uname
password: pass
so I just added the test line above the rest of the databases at the top of the file
The problem is I cannot even check to see if that's working right because when I try to run the parallel_tests gems, it returns empty!!!!
This is the guide I've been following, with the exception of finding out I had to require parallel_tests/tasks into my rakefile: https://github.com/grosser/parallel_tests
I have require 'parallel_tests/tasks' in my rakefile
I run the 3 commands in the parallel_tests gem to get execution running (don't worry about the java options and java tool options)
As you can see, there are no error messages, nothing out of the ordenary other then my tests do not run with or without the parameters to the features task. The following is a printout of the trace stack
Was running this on a windows machine... Windows doesn't support forking which is what this gem does.
Update, the newer versions of the gem allow you to run on any platform, with a new command. parallel_cucumber is the new command. Check https://github.com/grosser/parallel_tests for more details