ruby-on-rails

I can't get rails plugin wicked_pdf to work

Hi, I wanted to create PDFs for my rails application using wkhtml2pdf and wicked_pdf. I downloaded and extracted wkhtml2pdf beta 4 and placed it in /usr/local/bin/wkhtml2pdf I tried running it on a web site and it gave a nice result. In my rails application (2.3.4) I installed wicked_pdf: script/plugin install git://github.com/mil...

What to do about failed native extension builds in gem on Windows?

A couple of Rails applications I downloaded have dependencies on bson_ext which appears to be a native code library. When I run rake gems:install for the app I get the following error message: ERROR: Error installing bson_ext: ERROR: Failed to build gem native extension. d:/Ruby187/bin/ruby.exe extconf.rb checking for asprint...

How can I set environment variables in glassfish for a specific application (or domain)

Okay here is my setup: Running JRUBY (and a JRuby on Rails application) on a glassfish server (not gem!!!). Jruby has been installed via RVM (http://rvm.beginrescueend.com/). The RoR application has it's own gemset. (managed by rvm) Now my problem is, that I don't know how to tell glassfish to use a different GEM_HOME and GEM_PATH env...

SASS error: Properties arent allowed at the root of a document?

I keep getting an error like this: Sass::SyntaxError: Properties aren't allowed at the root of a document. on line 2 of /Users/eumir/rails_apps/neo2/public/stylesheets/sass/ main.sass main.sass's line 2 starts with @import mixins I have a _mixins.sass which has a variable declaration on line 2: $alt_site_color: #060 $main_s...

Rails 3 renders Haml file as Html

Following the guide at http://github.com/fortuity/rails3-mongoid-devise I've managed to setup Rails3 with Haml, Devise, and Mongoid. (As a side-note, the guide is really detailed; recommended reading for new Rails users!) Only problem is I can't get Rails to render my Haml views: Started GET "/" for 127.0.0.1 at 2010-07-01 14:40:23 +02...

Why is :if not being recognised by ActiveRecord validations?

I have a problem where an :if clause within an ActiveRecord validation is not being honoured. My model has an ip_port attribute which I am validating as being present, numeric and within a certain range. I am trying to ensure that each condition only generates one error. I do not want the situation where an empty attribute results in th...

How/what does the rails bin/rails file do.

Now, I've used Rails enough to know what the rails command does, but how it does it interests me. The bin/rails file (from github) is as follows: #!/usr/bin/env ruby begin require "rails/cli" rescue LoadError railties_path = File.expand_path('../../railties/lib', __FILE__) $:.unshift(railties_path) require "rails/cli" end As...

Different set of Views for different user's roles

I am developing a rails app and I have 2 different user's role: advanced and basic. Instead of to hide links in the basic user's views (a.i. using CanCan ) I want to manage 2 different set of views: one for the advanced user and one for basic user. Currently I am working in this way: case current_operator.op_type when 'basic' ...

interesting rails association challenge

I have stumbled on an interesting challenge regarding active record associations: I have an Account model which can have multiple and different organisations attached to it (like for example a Company, a Contractor, a Person) and it also has a different role with each association (accountant, owner, viewer, etc.). So I am not sure what...

Rendering a partial within "<code" or "<pre>" tags with jQuery and Rails

I am working on a simple Rails/jQuery HTML templater app which stores a series of pre-designed templates in a database (at the moment I've just saved these as partials to get the basic concept working) and on clicking 'Show code' alongside any one of these template records, a js.erb script should place the corresponding partial within 'p...

gitorious install won't login

I have installed a copy of Gitorious on my own server. Everything so far seems to be okay except the fact I can't login. Any attempt to login(with correct credentials), from multiple browsers, just throws me back to the main page. Logging in with wrong password will just clear password box. What could be causing this? ...

named_scope -- Finding entries where the field is neither null nor empty/blank

I only want to find the records that aren't null or empty/blank, currently I have; named_scope :in_gallery, :conditions => ["gallery IS NOT NULL"] (gallery is a string) but if the user inputs then deletes a title then this empty string is included in the results. to clarify I want to be able to select only the entries where the field...

Could not find RubyGem rake (>= 0) (Gem::LoadError)

Hi, I'm having a hellava time with Rails these past two days. I was using the Rails 3 beta gem yesterday but went back to 2.3.8 and after cleaning the system gems and whatnot I'm just trying to run a simple rake task and I get this: Peleliu:haml jayfallon$ sudo rake install /Library/Ruby/Site/1.8/rubygems.rb:779:in report_activate_error...

Auto moderating comments with Rails

We have a requirement to have comments on an application auto-moderated for obscenities etc. There will still be a real world moderating looking at comments, but they want to filter out the really bad stuff automatically. What would be the best way to do this? ...

What's the best way to move everything off of system folder on to s3?

Exploring around S3's UI, it seems they only enjoy file uploads from my local box. Is there a way to push the files directly from my production server to an s3 account? ...

Learning RoR and Mongo, why not count the array for votes

I'm completely new to Mongo and RoR, coming from a PHP background. I was just going through this tutorial about data modelling http://www.mongodb.org/display/DOCS/MongoDB+Data+Modeling+and+Rails and was struck with the question of why the tutorial would recommend storing the votes in a field and updating that field as db.stories.upda...

Ruby xAuth support

I'm currently working in a service that has an API access through Oauth. I recently noted than Twitter will add support to xOauth, a lighter protocol intented for mobile and desktop access. It's possible to add xAuth support for my site or is only a Twitter technology? Thanks, Toño ...

In rails controllers, how to prevent double submit (when user double-clic submit button or hit enter twice) ?

Well, everything's in the title but I'll explain a little more :-) My rails app contain many forms (Ajaxified or not). To prevent users to submit twice or more some forms, I use Javascript. There's my scenario for a Ajaxified form : the user submit the form (clic or enter) the javascript disable the submit button the rails controlle...

A Good Design Pattern for Ruby on Rails with Ajax for the following scenario?

I have two models A and B where updating B in some cases causes updates to A as well (done in model code). Now, in my UI, I want to display A and B in same page and can have their own operations (e.g. update some field in them). I don't want to reload the whole page on any update. My question is: I would like to put UI code for A and B...

Rails - validates_uniqueness_of: access duplicate item??

I have a basic Rails model with two properties, name and code. I have validates_uniqueness_of for the code property. However, I'd like to customize the :message to show the name of the duplicate. Is there any way to access this duplicate item? For example, say I first enter a record called Expired with code EXP. Then I enter Experie...