ruby-on-rails

Repeated Rake Task Using Delayed Job

Hello, I am currently using the delayed_job gem and I was wondering how to run a rake task every 5 minutes. I want to run "rake ts:reindex RAILS_ENV=production" every 5 minutes but I'm not sure where to start. I really don't have much more I can say about this because I am VERY inexperienced in this area of rails development. ...

Advanced Rails Routing of short URLs and usernames off of root url

I want to have username URLs and Base 58 short URLs to resources both off of the root url like this: http://mydomain.com/username #=> goes to given user http://mydomain.com/a3x9 #=> goes to given story I am aware of the possibilities of a user names conflicting with short urls, and I have a workaround, but what I can't figure out is ...

How to modify partial, depending on controller it's viewed from?

I'm using a partial from my "messages" controller in my "tags" controller. The portion in question looks like this: <% unless message.tag_list.nil? || message.tag_list.empty? %> <% message.tags.each do |t| %> <div class="tag"><%= link_to t.name.titleize, tag_path(t) %></div> <% end %> <% end %> Is there a way to hide...

Rails uniqueness constraint and matching db unique index for null column

I have the following in my migration file def self.up create_table :payment_agreements do |t| t.boolean :automatic, :default => true, :null => false t.string :payment_trigger_on_order t.references :supplier t.references :seller t.references :product t.timestamps end end I want to ...

Redirecting all page queries to the homepage in Rails

I've got a simple Rails application running as a splash page for a website that's going through a transition to a new server. Since this is an established website, I'm seeing user requests hitting pages that don't exist in the Rails application. How can I redirect all unknown requests to the homepage instead of throwing a routing error?...

Facing Problem with libxml.rb

Hi Folks, I downloaded one of the rails app from server and tried running it. I faced an error on migration D:\Radiant\trunk>rake db:migrate (in D:/Radiant/trunk) rake aborted! 126: The specified module could not be found. - D:/Radiant/trunk/config/../ven dor/plugins/libxml-ruby/lib/libxml_ruby.so I got the windows version of libxm...

How to prepare an interview for Ruby on Rails developer position?

Background about myself: I have about 3 years experience working in Java/J2EE. I am currently pursuing MS in Software Engineering at a reputed university. I have done several classwork projects on Ruby on Rails and can be considered at Intermediate level expertise with ROR. I have an interview coming up next week for a Ruby on Rails de...

Setting many key/value pairs

Hi, I'm working on a rake task which imports from a JSON feed into an ActiveRecord called Person. Person has quite a few attributes and rather than write lines of code for setting each attribute I'm trying different methods. The closest I've got is shown below. This works nicely as far as outputing to screen but when I check the value...

.save puts NULL in id field in Rails

Here's the model file: class ProfileTag < ActiveRecord::Base def self.create_or_update(options = {}) id = options.delete(:id) record = find_by_id(id) || new record.id = id record.attributes = options puts "record.profile_id is" puts record.profile_id record.save! record end end This gives me ...

require file use dirname(__FILE__) or just requre filename?

I have a file at lib directory in my rails project. like this a (directory) a1 a2 a.rb when I in a.rb require a1. require 'a/a1' it will warn me /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- a/a1 (MissingSourceFile) but use dirname(FILE), it work. require File.dirname(__FILE...

How to skip certain tests with Test::Unit

In one of my projects I need to collaborate with several backend systems. Some of them somewhat lacks in documentation, and partly therefore I have some test code that interact with some test servers just to see everything works as expected. However, accessing these servers is quite slow, and therefore I do not want to run these tests ev...

What tech stack/platform to use for a project?

Hey guys, This is a bit of a weird meta-programming question, but I've realized that my new project doesn't need a full MVC framework, and being a rails guy, I'm not sure what to use now. To give you a gist of the necessary functionality; this website will display static pages, but users will be able to log in and 'edit their current...

Unable to read excel files in Production environment but working in dev environment

Using Spreadsheet GEM, I am able to read xls files in development environement. As I move to production server, application is unable to read xls files. Please help what can be the likely changes I am missing on to make it work in production environment too. Thanks in advance ...

Top stories in RSS reader

How do you know what are the top stories or hot topics just in RSS feed aggregator NewsNow for example?? Could you please explain? I am new to Ruby on Rails. I want to build a RSS reader in Ruby on Rails. Could you suggest me some good tutorials or links?? Thanks Gautam ...

Rails uses wrong class in belongs_to

I have an application managing software tests and a class called TestResult: class TestResult < ActiveRecord::Base belongs_to :test_case, :class_name => "TestCase" end I'm right now migrating from Rails 1.x to 2.3.5. In Rails 1.x everything works fine. When trying to access the association in Rails 2.3.5, I get the following err...

form serialize problem

I have a form. I am trying to validate it through AJAX GET requests. So i am trying to send the field values in the GET request data. $('#uxMyForm').serialize(); the problem it is returning something undecipherable. I have used serialize before. This is totally bizzare. the return value of serialize is actionsign_upcontrollersite...

developing facebook applications with ruby: which gems to use?

i am currently planning a facebook application to be developed with ruby on rails. i stumbled upon the facebooker gem, but there seem to be other gems around as well - actually there is also a facebooker2 gem. what are the current options i have with ruby on rails and facebook development? which gems are recommendable? ...

Highlighting the current page in rails, only works for some pages

I've used this tutorial to highlight the current page in the menu. I have a pages controller with a few static pages, for the home page I simply have def home @title = 'Home' and similar for contact pages etc. Then in my main layout file I have <body class="<%= @title %>"> and this works fine to set the correct css, but how do I set @...

URL Encoding in JS for meaningful URLs and Rails Page Caching

Hi, I'm running a Rails Application which gets a lot of traffic at the moment so I started using Page Caching to increase the performance. So far everything works like a charm. But when I tried to also cache search results I run into a strange problem. My Approach: Use meaningful URLs for searching and pagination (/search?query=term&...

is it right to assigning multiple variable like this a = b = c = d = 5 in ruby?

a = b = c = d = 5 puts (a) >> 5 puts (b) >> 5 puts (b) >> 5 puts (b) >> 5 a= a+1 puts (a) >> 6 puts (b) >> 5 i found there is no problem with the assigning value like this. my question is should one assign like the one given above or a , b, c, d = 5, 5, 5, 5 ...