Use; set_table_name :name_of_the_table in your model (E.g) class myTable < ActiveRecord::Base set_table_name :media end
Archive for the ‘Ruby on Rails’ Category
Single/custom table name for a model in Ruby on Rails
Posted in Ruby on Rails, tagged lessons, Ruby on Rails on June 20, 2009 | Leave a Comment »
Generating sitemap in Ruby on Rails
Posted in Ruby on Rails, tagged lessons, Ruby on Rails on April 27, 2009 | Leave a Comment »
Create a controller with the name ‘sitemap’ (or) with the name you desire….. (E.g) ruby script/generate controller sitemap (or) You can manually create one [app/controllers/sitemap_controller.rb] When you view the ‘controller file’ which you created just now, it would look like; class SitemapController < ApplicationController end Once it’s done, we need to add the functionality to [...]
Running Rails code through a cron job
Posted in Ruby on Rails, tagged Ruby on Rails, tips on April 7, 2009 | Leave a Comment »
Rails comes with a script/runner script that can be used to run the code in your Rails app. There’re many ways to organize your code to let this runner script execute it, but one obvious way is to write the code as a model’s action. Here are quick steps for doing this: 1. Insert the [...]
(uninitialized constant DBI::TypeUtil) (DBI::InterfaceError)
Posted in Ruby on Rails, tagged bug fixes, ruby on February 26, 2009 | 1 Comment »
use; require ‘rubygems’ gem ‘dbi’ before the line; require “dbi”
undefined method `gem’ for main:Object (NoMethodError)
Posted in Ruby on Rails, tagged bug fixes, ruby on February 26, 2009 | Leave a Comment »
Try using; require ‘rubygems’ in the firt line. That should fix your problem.
Rails Freeze
Posted in Ruby on Rails, tagged lessons, Ruby on Rails on January 11, 2009 | Leave a Comment »
To Freeze to your installed version of rails: rake rails:freeze:gems Freeze to edge rails (latest version, probably not a good idea as rails has had some radical changes lately. If you want to do RESTful, then go for it). rake rails:freeze:edge Freeze to a specific version, eg 1.2.3: rake rails:freeze:edge TAG=rel_1-2-3
undefined method fragment_cache_store=
Posted in Ruby on Rails, Weird Errors, tagged bug fixes, Ruby on Rails on December 18, 2008 | Leave a Comment »
Make it ‘cache_store‘ insted of ‘fragment_cache_store’ It should look something like, ActionController::Base.cache_store = :file_store, “../my_cache”
undefined method template_root=
Posted in Ruby on Rails, Weird Errors, tagged bug fixes, Ruby on Rails on December 18, 2008 | Leave a Comment »
template_path has been not only deprecated but is now gone. Try changing it to view_paths
Handling Multiple foreign keys in Rails
Posted in Ruby on Rails, tagged lessons, Ruby on Rails on December 15, 2008 | Leave a Comment »
In some cases, you may want to have multiple foreign keys map to a single model. The following example explains how the “user_id” and “favorite_id” in a single table(Favourites) map to the User Model(table). class Favourite < ActiveRecord::Base belongs_to :user belongs_to :favourite_user, :class_name => “User”, :foreign_key => “favourite_id” end Now you can play around without [...]
Rails request.env[:HTTP_REFERER] returning nil
Posted in Ruby on Rails, tagged bug fixes, Ruby on Rails on December 10, 2008 | Leave a Comment »
Try, request.env[:REQUEST_URI] instead. That should fix your problem.