ruby-on-rails

jquery-watermark plugin and HTML5 email input type not working correctly

diveintohtml5 says it's okay to start using the email form type. So I am trying it out on one of my forms. I'm using jQuery and a plugin called jquery-watermark. It makes the placeholder element work across browsers. The plugin still works on Firefox 3.6 but on Opera 10.61 and Chrome 6 the placeholder isn't rendered. <script type="text...

Rails 3 is out, but will they still support Rails 2.3.x?

Rails 3 is out and every one is excited (etc etc). However, I'm not ready to update to it yet for a couple reasons: Not all gems I use are supported. Just finally got my head around 2.3.x. My client expects software that is reliable. So, right now I'm running 2.3.5 and will be upgrading to 2.3.8 soon. But what about any security pat...

Getting Mongoid from params array

In order to find a Root Document that contains a embedded document using MongoID/Rails 3 I need to do my query this way: QuoteRequest.where( "order_request_items._id" => BSON::ObjectID(params[:id]) ).first Is there a way to query without using the BSON::ObjectID ? Thanks! ...

Updating part of a web page on Rails

I have a Rails controller with a form, and I want that when I post this form, a table on this page is updated via AJAX. I know a way, using partials to achieve this, but is that any way to do this without partials? And without putting code for my view inside my controller too. Thanks ...

Rails creating local xml file

I need to create a local xml file from a rails application and then copy it to a location on another server. I have tried using the File.new option to create a new file but it gives me an error saying the file does not exist. After looking closer at the documentation it says that File.new opens a file that already exists. I can't see ...

ASP MVC, Django or Rails?

I've to start my master thesis project and I've to choose a technology to work with. I've used Rails and ASP MVC, in two projects, but never used Django, only some play with it. But I've some experience with python and really like the admin interface. The objective of my master thesis is a creation of portal to a public hospital. I hav...

Length of a unicode string

In my Rails (2.3, Ruby 1.8.7) application, I need to truncate a string to a certain length. the string is unicode, and when running tests in console, such as 'א'.length, I realized that a double length is returned. I would like an encoding-agnostic length, so that the same truncation would be done for a unicode string or a latin1 encoded...

Where to find old Rails 2.3 Guides

Since Rails 3 is out, all the guides on http://guides.rubyonrails.org/ are for Rails 3. I used to reference the guides for 2.3 a lot. Is there anywhere they're still available? ...

In rails, how to destroy an 'join table item' with out delete the real record?

Hi guys: I get confuse now, I don't know how to delete/destroy a record in a join table: class Task < ActiveRecord::Base belongs_to :schema belongs_to :to_do end class Todo < ActiveRecord::Base belongs_to :schema has_many :tasks end class Shcema < AcitveRecord::Base has_many :todos has_many :tasks, :through => :todos e...

Net::HTTP POST with XML Payload and some URL Parameters

Hey guys, Just a quick question, when I do request = Net::HTTP::Post.new(path) Can I do path = '/api/v1/baskets?apiKey=' + api_key + '&sig=' + sig + '&time=' + time Where api_key sig and time are some string or do I need to do path = '/api/v1/baskets' request.set_form_data({'apiKey' => api_key, 'sig' => sig, 'time' => time}) ...

I have a Rails app and need to implement a "universal" or "skeleton key" password using AuthLogic

I have the AuthLogic plugin installed in my RoR app. I not creating an app that needs to be high security. But I would like it if admins can log in as a particular user without having to know each and every one of their passwords. I cannot find where AuthLogic actually validates the entered password upon login. Anyone have any recomme...

Rails 3: Passenger can't find git gems installed by bundler

Rails 3.0.0, Passenger 2.2.15: Create a new Rails project Add gem 'paperclip', :git => 'git://github.com/lmumar/paperclip.git', :branch => 'rails3' to your Gemfile Do bundle install Everything OK, starting with rails/script server & accessing also works However, when accessing with Passenger, it says: git://github.com/lmumar/papercli...

Adding custom directories (source and spec) to autotest in a Rails 3 project

I have a Rails 3 app that uses RSpec2 as my testing framework, and I'm able to use autotest to watch my model and spec directories for changes and re-run my spec suite when files change. I'd like to add a directory with some custom classes in it (RAILS_ROOT/lib/some_project/lib/*.rb) and their corresponding specs (RAILS_ROOT/spec/some_p...

Should I use a Rails integer or string for this number?

In my Rails 3 app, I am creating a Book model which contains an ISBN column. This ISBN value will be a number 13 characters long. Which type should I use to create the ISBN column? Should I use an :integer or a :string? What is the maximum size of an integer in Rails? rails g scaffold Book title:string isbn:integer ...

Rails's open source projects with best practices and/or code standard?

I would like to know some of the great opensource projects in Rails with some best practices and/or code standard including unit testing, so that I can learn some experiences from building apps from those sources. ...

Ruby question about # Signs

As seen here: http://railstutorial.org/chapters/rails-flavored-ruby#top for the file: app/helpers/application_helper.rb: module ApplicationHelper # Return a title on a per-page basis. def title base_title = "Ruby on Rails Tutorial Sample App" if @title.nil? base_title else "#{base_title} | #{@title}" en...

How to have users create scheduled tasks in rails app deployed on Heroku

I have a rails app deployed on Heroku. I want to add a feature that enables users of the app to set a reminder. I need some way for the app to schedule sending an email at the time specified by the user. I have found numerous posts referring to using delayed_job for this, but none of the write-ups / tutorials / etc. that I have found ...

Ruby on Rails - How to pass hash parameter to a partial view?

Hi, I use this: <%= render :partial => 'shared/subscription' %> To call this partial view: <% form_for(:subscription, :url => city_subscriptions_path(@city)) do |form| %> <%= form.hidden_field :city_id, :value => @city.id %> <%= form.text_field :email, :size => 30 %> <%= form.submit "Email Me" %> <% end %> Since I am using th...

Default conditions for Rails models

I have a model which has a field called deleted, which is used to mark those deleted items. So normally I would just want to query those having deleted = false items, and in some special cases to list those deleted items for restoring. Is it possible to do that? What I could do now is just using a named scope having :conditions => {:de...

Date select : default year selected

On form 1, I have a formtastic date_select field. = f.input :date_from, :discard_day => true, :discard_month => true, :order => [:year], :start_year => 1950, :end_year => Date.today.year, :include_blank => ...