ruby-on-rails

Recommended rdf usage in Ruby on Rails

I'd like to publish rdf in my rails apps. What's the right way to do it? ...

Authlogic problem in production mode: undefined local variable or method `acts_as_authentic' for class name

Hello Everyone, I'm using the AuthLogic gem in my rails app. It works fine in the development environment but when I switch to production environment, I get an error preventing the app from starting: /home/.../rails/xxx/app/models/book.rb:2: undefined local variable or method `acts_as_authentic' for Book:Class (NameError) from ...

"Like", "Dislike" plugin for rails

Is there any "like" , "dislike" plugin for rails... I went through rating plugins... but all of them were 5 star rating plugins... ...

Is there an AJAX function that can just GET a rails partial ?

My controller is shared by links from a search result page that needs a layout, and from the profile page itself that does not need a layout. What I would like to accomplish is a single controller method show that is both capable of drawing the partial by AJAX from the profile page, and draw the partial and layout from the search results...

workling & RabbitMQ

Hi For my project I would like to run some jobs in background using workling (publish some data to the queue) but I'm getting errors while trying to configure my app (unitialized constant MemCache) I'm using Fedora 13 + ruby enterprise edition My questions are Has anybody worked with workling recently ? Was everything fine ? Did you ...

inconsistant output from JSON.stringify

Sorry if this is repost but I couldn't find my question after I posted it. I have a rails app that is rendering a json string and storing the same sting in the db. The output from the initial page that receives the output and the page that displays the data from the db have different output. The data and the function to format the data a...

Better way to write if condition in ruby.

if args.size == 5 value_for,alt_currency_id,amount,exchange_rate_code,tran_dt = args else value_for,alt_currency_id,amount,exchange_rate_code,year_no,period_no = args end Any Better way to write this condition ?? ...

What's the difference between design pattern and enterprise design pattern?

Hi, I want to know the difference between design pattern and enterprise design pattern. For example, some books call ActiveRecord an enterprise design pattern, while, singleton is a design pattern. Thanks ...

how to import data into rails?

I have a Rails 3 application with a User class, and a tab-delimited file of users that I want to import. How do I get access to the Active Record model outside the rails console, so that I can write a script to do require "???active-record???" File.open("users.txt", "r").each do |line| name, age, profession = line.strip.split("\t"...

Getting started with Authlogic -- is this what I am looking for?

I'm looking to build an application that handles authentication and authorization for a variety of smaller apps that may or may not be rails applications (e.g. some with sinatra, some with non-ruby frameworks, etc). These applications will be on separate domains. Can I do this with Authlogic? I do not want to setup a rails application f...

OAuth Provider Service and Rails 3

I am trying to look into setting up an OAuth Provider Server with Rails 3 but can't seem to find anything out there to accomplish this. I am also a newb when it comes to oauth, so excuse my ignorance. When setting up an oauth server do I need to already have an oauth account at somewhere like agree2.com? Or can I just use my own serve...

Ruby on Rails: Update page multiple times in controller

So I have a rather long controller function that performs various tasks, and it takes around 10-15 seconds. I want to be able to update the user on the status of the function as it goes along (progress bar). Ideally, the function is called as an Ajax request, and would then update the page as it goes along. This would work except you can...

How do I get my application.js (jQuery) file to execute a script from somewhere else in my Rails app?

I'm starting to feel crazy because what I want to do is so simple: write a line of javascript in my Rails application.js file that will cause a script somewhere else in the app to execute. I've tried it with jQuery.get() and jQuery.getScript() but nothing seems to work. Here's some sample code from my application.js file: #application....

Install twitter gem on windows7

Trying to setup a windows development machine for a Rails project that has a dependency on the twitter gem. I get an error when I try and do gem install twitter. It needs to build native extensions and using --platform=mswin32 didn't work like for other GEMs Using ubuntu is really not an option. I need the computer I am using for too...

Rails, saving the foreign key in a `belongs_to` association.

I think I'm having a really basic problem here but I can't seem to put my finger on what I'm doing wrong. So the issue here is when I save an instance of a model the foreign_key for the models's belongs_to association (in this case the user_id is not being saved, so I'm forced to do this: def new @thing = Thing.new(:user_id => curre...

Rails: Images on one server, CSS and Javascript on another

Hi, I am working on a rails app that has a bunch (hundreds) of images that are hosted on an S3 server. To have helpers like image_tag point here I had to add this to by config/environments/development.rb test.rb and production.rb: config.action_controller.asset_host = "http://mybucket.s3.amazonaws.com" However, this also means that it...

Ruby on Rails: How are people making search forms on sites with the broken textfield parsing that removes quotation marks?

I'm using Sunspot Solr search, which works fine for the most part for basic search. It's supposed to be able to handle quotation marks around phrases, so that a search for test case will return documents with both test and case, whereas a search for "test case" should return documents with the phrase test case. However, I've been pullin...

Rails new GEM_HOME

I recently upgraded to Ruby 1.8.7 (had an issue with 1.9.2) and had to reinstall RubyGems. Now my project can't see any of the old gems in my GEM_HOME, is there a way to point my new gem binary to my previous GEM_HOME? I can't find anything online and it's a big pain to install them all again one by one. I'm also on a Mac, so it's at:...

Ruby on rails: Devise, want to add invite code?

Hi, I would like to add an invite_code requirement for users to sign up. Ie. in addition to requiring them to specify an email/password combo, I want an additional field :invite_code. This is a temporary fix so that non-wanted users cannot login during a given alpha period. I'm confused since Devise doesn't add controllers. I'm sort o...

Disabling ActiveModel callbacks

I published an article on disabling ActiveModel callbacks, but I’m not completely sure this is the prettiest way to do something like this. Mongoid::Timestamps adds a before save callback that updates the updated_at field. Let's say I don't want that in some cases and I disable the callback like this: class User # I'm using Mongoid, ...