ruby-on-rails

undefined method `getlocal' for Sat, 30 Oct 2010 08:32:42 +0000:DateTime with Ruby 1.9.2

I'm getting this error since I updated to ruby 1.9.2p0 (2010-08-18 revision 29036) & Rails 3.0.1. How can I fix it? undefined method `getlocal' for Sat, 30 Oct 2010 08:32:42 +0000:DateTime activesupport (3.0.1) lib/active_support/time_with_zone.rb:75:in `localtime' activerecord (3.0.1) lib/active_record/connection_adapters/abstract/quo...

jQuery Edit in Place - Plugin

Hello, I wanted check-in with all the jQuery folks to see, whats the latest, best plugin for In Place Editing? I've used Jeditable way back when and figured there is likely something better by now as Jeditable doesn't appear to be maintained and it's a huge download (24kb+s?) Any suggestions? I'm using Rails 3, so hopefully it supports...

In Rails, why "action_controller/benchmarking.rb" is running?

While checking why a page is loading fairly slowly, I saw that /vendor/rails/actionpack/lib/action_controller/benchmarking.rb is being run. Why is it running (is it something in the config file? or is it something standard in development mode?) Won't it cause a page to load extra slow? Is there a way to turn it off? (using Rails ...

Rails3 irb console vs rails console?

Using Rails3 and Ruby 1.9.2, I am new, just learning Ruby/Rails-- When I run irb I end up with irb(main):001:0> which is fine. However when I run rails console I also end up with irb(main):001:0> and I thought, based on the book I'm reading and online tutorials that I should be seeing >>. Is the Rails Console I'm thinking of a gem that...

How can I set the default for a column as a GUID?

How can I set the RoR model's property (database column) to default for a column do generate a GUID in mysql? Does the column have to be a unique identitifier or can I have it be a string of length 36 also? ...

Rails: create parent, using parents own view, while creating child record

While part way through entering a new record(child), that is incomplete and can't be saved, I want to be able to add a record to another model(parent) and then use it to complete the original record(child). The parent has many required attributes, not just a single field. I want to do it in as dry a way as possible using the new/create v...

hash.delete_if { |key, value| true } doesn't delete ... why?

I am working on the acts_as_taggable_on plugin, but there is something I can't really understand (even if it is just a very simple code line). puts "before: " + cache.inspect # cache.delete_if { |key, value| key.id == owner.id TaggableUser id: 1, name: nil>=>["dog"]} after: {# TaggableUser id: 1, name: nil>=>["dog"]} My problem is tha...

Rails, production-env, "Object is not missing constant"

So I seems I was stupid and haven't checked running in production-env for a long time, and now that I'm trying to deploy, I'm getting this annoying error. Any ideas? lib/history_tools.rb module HistoryTools def self.included(base) base.has_many :history, :dependent => :destroy History::TYPES.each do |htype| base.has_man...

Is it possible to discover the expected params that is required in order to POST successfully?

Here is the scope of the issue Im dealing with... I just took over an existing rails app that has a very complex business logic. The app is being used as a service. Json in, Json out. Some of the resources expecting to find an abstract model in params hash and then via meta programming it expects to find the right object properties pro...

Can "auto_increment" on "sub_groups" be enforced at a database level?

In Rails, I have the following class Token < ActiveRecord belongs_to :grid attr_accessible :turn_order end When you insert a new token, turn_order should auto-increment. HOWEVER, it should only auto-increment for tokens belonging to the same grid. So, take 4 tokens for example: Token_1 belongs to Grid_1, turn_order should be 1 up...

Converting UTC timestamp to ISO 8601 in Ruby

I have a timestamp that is in UTC "2010-10-25 23:48:46 UTC" I need to convert it into ISO 8601 "2010-10-29 06:09Z" The documentation is confusing as hell - what is the easiest way to do that? ...

How to create a new object, passing it some parameters, and then saving it.

I want to create a new object, passing it some initial values, and then saving to the db and return the saved object. how can I do this? example: create a new user object initiaze the user.user_age property to 35 save and return the saved object b/c I need access to the user.user_id value. What's the ruby way of doing this? ...

dose rails scaffold command support generate belongs_to or many to many model middle table migration info?

Product,Category is two model on rails3 the relation between them are follow: product has_and_belongs_to_many categories category has_and_belongs_to_many products i can use scaffold generate migration for this two modle use rails g scaffold product name:string rails g scaffold category name:string but how can i generate the many to...

Text field with date, how can I change the date format that Rails is expecting?

I have a text field which is filled with a date from the jQuery UI Datepicker. Depending on the date format the user has selected in their profile on my site, datepicker will either fill in the text field with DD-MM-YYYY or MM-DD-YYYY. If the date is filled in as DD-MM-YYYY, Ruby on Rails interprets this correctly and the date is stored ...

Rails - News Feed

Alright here's the trickiest question I've ever had to ask on StackOverflow. My Web App allows creating a document. This document is automatically saved lets say ever couple of seconds. Meanwhile, I want a news feed to lets users know what there friends are up to. So I created a observer model which after_create creates a news_feed typ...

Restrict characters entered into a text_field

I have a text field where users enter a URL string, which cannot contain spaces or non-alphanumeric characters (if that's an accurate way of putting it). Is there a way in Rails to restrict entry into the text_field itself so that spaces and characters like /":}{#$^@ can be avoided? Thanks a lot. To clarify, the only characters that...

Rails: Store JSON in MongoDB

Hello, I am getting multiple similar JSON object from a remote site and looking to store them in a local MongoDB. What would be the best way to do this ? (Preferably via Mongoid or Mongo-mapper gems) Thanks ...

invoke method on rails3 view hepler problem

i have two view helper module Admin::CategoriesHelper def test return "a" end module CategoriesHelper def test return "b" end i invoke test method in views/admin/categories/index.html.erb ==================================================================== if i use Admin::CategoriesHelper.test it will...

rails -v errors when setting up rvm

Hi, I am trying to set up an environment as per this tutorial http://railstutorial.org/book#sec:1.2.2.3 however I get the below error when running 'rails -v' bash-3.2$ rails -v /Users/sandbox1/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/rubygems.rb:762:in `report_activate_error': Could not find RubyGem rails (>= 0) (Gem::LoadError) ...

will-paginate issues for searchresults in ruby on rails

hi guys, my search results are stored in the @searchresults variable as subarrays - for example it has 3 sub-class of results books, people, carnames, such that each of this results are available in the search result as @searchresults[:books_results] etc,. I need some help on how to apply the will_paginate for these sections (books, peo...