rails

Converting queries to AREL

Tagged:  

A little bit of ConnectWise SQL converted to AREL, https://github.com/rails/arel. Took me a while to work out how to do the left joins, be we got there. To me it would be nice to have a 'outer_join' or 'join_outer' method which does 'join(x, Arel::Nodes::OuterJoin)'.

A little bit of ConnectWise SQL converted to AREL, https://github.com/rails/arel. Took me a while to work out how to do the left joins, be we got there. To me it would be nice to have a 'outer_join' or 'join_outer' method which does 'join(x, Arel::Nodes::OuterJoin)'.

select *
from config c
 join cs_survey s ON s.cs_survey_recid = c.cs_survey_recid
 join company ON c.company_recid = company.company_recid
 left join agr_config on agr_config.config_recid = c.config_recid    

You provided devise_for :users but there is no model User defined in your application

Tagged:  

I have been working on getting LDAP and database auth going on a rails app with Devise.

All was going well until I started getting this error on start up.


$ rails server
=> Booting WEBrick
=> Rails 3.0.5 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[WARNING] You provided devise_for :users but there is no model User defined in your application
[2011-04-14 19:56:18] INFO WEBrick 1.3.1

FasterCSV -> CSV for ruby 1.8 -> 1.9 and rails 3.0

Tagged:  

Ran into an issue with a rails 3.0 app which I had running on ruby 1.9 and am now getting to run on ruby 1.8. The app pulls in data from some CSV files and used the CSV library in ruby 1.9. All the CSV data imports failed under ruby 1.8. A little research showed that this is because CSV in ruby 1.9 was FasterCSV in ruby 1.8, and the CSV class in ruby 1.8 was something completely different. So I got around this by doing the following:

Add a conditional include of fastercsv to the Gemfile:

gem 'fastercsv', :platforms => :ruby_18

Rails 2.2.2 and will_paginate bug

Tagged:  


NoMethodError (undefined method `extract_attribute_names_from_match' for #):
/usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/base.rb:1833:in `method_missing_without_paginate'
/usr/lib/ruby/gems/1.8/gems/will_paginate-2.2.2/lib/will_paginate/finder.rb:164:in `method_missing'
/usr/lib/ruby/gems/1.8/gems/will_paginate-2.2.2/lib/will_paginate/finder.rb:206:in `wp_count'
/usr/lib/ruby/gems/1.8/gems/will_paginate-2.2.2/lib/will_paginate/finder.rb:85:in `paginate'

A quick introduction to Perlbal

Tagged:  

If you're hoping to one day reach the point where your web application is growing to hundreds or thousands of hits per second then you need to be ready to scale out. One part of this involves being able to balance the load across a few backend servers, or just splitting your requests between static content (images, css, javascript) and application content. Enter Perlbal.

Yet more getting rails to run under OpenSolaris

Tagged:  

Trying to add some data to my new project using the default sqlite3 database. And so the first issue:

$ /usr/ruby/1.8/bin/rake db:migrate
(in /export/home/jeffw/network)
rake aborted!
no such file to load -- sqlite3

No worries I say, just install the sqlite3 gem, but alas:

$ pfexec gem install sqlite3-ruby
....
/usr/ucb/install -c -m 0755 sqlite3_api.so /usr/ruby/1.8/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.4/lib
sh: line 1: /usr/ucb/install: not found

Installing rails on OpenSolaris

Tagged:  

Well, who would have thought it would be so difficult to get rails running on OpenSolaris. I wanted to quickly work up a new project in rails and have ended up spending a half hour getting rails running. Hopefully I can save someone else some time...

First, make sure ruby is installed:

$ pfexec pkg install SUNWruby18

This will install rubygems as well, BUT, on my first time round, I got to running rails and found out that:

Rails requires RubyGems >= 1.3.1 (you have 0.9.4). Please `gem update --system` and try again.

Syndicate content