ruby-on-rails

Groups have no effect with Bundler

Hi! I'm using Bundler gem 1.0.0.rc.6 and Rails 2.3.8 I specified a gem to be part of the production group in the Gemfile but, when I run a Rails console in dev env, that damn gem is loaded! I strictly followed the setup found on http://gembundler.com/v1.0/rails23.html Any idea ? Thanks ! Edit: BTW the 'problematic' gem is not loaded...

LoadError: no such file to load -- serialport

I have the serialport gem installed so I'm thinking there is something wrong with my paths. which ruby /usr/local/bin/ruby which gem /usr/local/bin/gem Also, it looks like I have two different versions of serialport gem: ruby-serialport-0.7.0 serialport-1.0.4 Could this be an issue? Also here is the error I got: Boot Error Som...

Where i put my module/class in ROR MVC architecture

Hello all, I have made a module named module ConstantModelName AIRPORT = "Airport" end It contains all the constant values used in my application. So where should i place this module in my application. currently i placed it in lib folder in my app. Give your valuable comments. Thanks ...

Cutsom Input for formtastic, what am i doing wrong?

Hi I have made a custom input method for formtastic, it is designed to work with carrierwave and it works great but with one exception, the preview image and other html will not render, as it is being sanitized (i think). Am i going about this completely the wrong way? Here is the code: def carrierwave_input(method, options) c = b...

Ruby on Rails :How can constants availables to my views.

module ConstantModelName AIRPORT = "Airport" end This module is in lib folder of my app. I want avialble this constant(AIRPORT) value to my views. Is this possible? If Yes, how can i do this? Thanks in advance ...

What does ; mean in Ruby?

I am trying to learn how to write plugins in Rails by learning other people's plugins, turns out it is way harder than I thought. I found this: module Facebooker class AdapterBase class UnableToLoadAdapter < Exception; end What does the fourth line: class UnableToLoadAdapter < Exception; end mean? What is the best book to learn...

Master-Detail on RoR with Ajax

What is the best pattern to do a master-detail form in Ajax using RoR? My form has an order and for each order there is a lot of itens. I want to do only one form where the user can set the order details and include, exclude and update itens. When the user insert an item, I am doing an AJAX call to my controller so the user can search fo...

Is it allowed to write code without method enclosure in a class / module? what does this code mean?

For example a file in active_support/core_ext/exception.rb it started with: module ActiveSupport if RUBY_VERSION >= '1.9' FrozenObjectError = RuntimeError else FrozenObjectError = TypeError end end Then continued with class Exception code what does it mean? What do you use FrozenObjectError, RuntimeError, and TypeError...

What is causing this redirect_to to fail?

I am trying to use this redirect_to redirect_to :controller => :note_categories, :action => :destroy, :note_id => params[:id] This is the URL that results http://localhost:3000/note_categories/272?note_id=272 and this is the error message Unknown action No action responded to show. Actions: destroy The reason I am redirecting to...

can i pass parameter with annotate_model rake task in rails.

I want to annotate a specific model not all. Can i pass a model name or table name with annotate_model rake task to annotate specific model ? ...

How to be an independent Ruby programmer

I am tired of asking unanswered questions when using many outdated plugins / gems, and sometimes they don't really work how I really wanted. So my question is simple: If I was a PHP programmer, and Rails was my first framework, what do I need to learn next so I can depend on myself when working with troublesome plugins or code snippets...

Ruby on Rails: Learning ActionController class - Question on $:.unshift activesupport_path and autoload method

Hi, Inside ActionController class (rails/actionpack/lib/action_controller.lib) I found several weird code. I don't really have a mentor to learn Ruby on Rails from, so this forum is my only hope: Question #1: Could anyone help me explain these lines of codes? begin require 'active_support' rescue LoadError activesupport_path = "#{...

How do you add a custom route to a singleton resource?

map.resource :basket, :collection => { :checkout => :post } The above does not work for a resource, as you would expect since basket is a resource (ie. singular) not resources, so there is no concept of a collection, everything should be scoped to the current_user. In this case User has_one Basket. However I would like to specify a ...

How to debug a plugin / gem? (with useful notes to setup and use ruby-debug gem)

Is there a way like how we debug models / controllers with logger.debug? Or even a better method? Thank you! Edit 1 Using ruby-debug seems like a steep learning curve for me, could anyone point me something similar to logger.debug, perhaps? Edit 2 Alright, I think I started to get a grasp on ruby-debug. Some useful notes for newbie...

How to debug a plugin or gem using ruby-debug gem, where the part I wanted to debug started from test scripts?

For example I have this gem called Authlogic-openid, that plugin is outdated, no longer supported, and broken (let me know if you know any alternative by the way). I wanted to make sure the test runs by keying ctrl+R on vendor/gems/authlogic-oid-1.0.4/test/acts_as_authentic_test.rb [Please do not attempt to try my steps below, the gem ...

RoR Path Helper link is backwards

I have a sentence model and set up in the routes.rb map.resrouces :sentence However, when I use edit_sentence_path(sentence) it sets up the url to be /sentence/1/edit instead of /sentence/edit/1 Am I missing something? I am not exactly sure if I am doing this correctly since I am trying to do the data access stuff without using...

Help me with posting with Net::HTTP

I am using a third-party API (Spreadshirt's API) and in order to perform a basket creation, I need to send an xml through a POST request. I am trying to do this with the available Net::HTTP functions and this is how I am doing it def get_session @time = Time.now.to_i * 1000 #get the current time as integer @sha1 = Digest::SH...

Rescue and redirect 500 Error in Rails when Database is not found

We had some patches for our Database applied the other day. I was not given a heads up, and the application went down. We are getting nothing but a white Status: 500 Internal Server Error Content-Type: text/html 500 Internal Server Error page. We are using Rails 2.2.2 I want to redirect the user to /500.html so that they get th...

Mongrel Cluster fails to start

Hello, I have an issue with Mongrel cluster start-up, when I start the cluster I am getting the following error: /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in 'gem_original_require': no such file to load -- /home/admin/test-project/test-app/config/environment (LoadError) log file link I am using this command to st...

Rails 3 and Factory Girl creating user only if attributes are passed in

Hey, I'm using Rails 3 rc, Factory Girl, and Rspec, and Authlogic. Is there any way or reason why this would happen: When I create a user like this: @user = Factory(:user) I get an issue with password confirmation being "too short". my factories.rb is Factory.define :user do |u| u.username "Test User" u.email "...