ruby-on-rails

How do I set a default sort order for a rails model?

I would like to specify a default sort order in my model. So that when I preform a find(:all, ...) without an :order parameter it defaults to the order specified in the model, but specifying an :order will override the default. ...

undefined method `destroy_unused' for Tag(id: integer, name: string):Class

I'm currently using acts_as_taggable_on_steroids on Rails 2.3.8. After configuring the plugin, when i try to destroy a post with a tag, it gives me this error: undefined method `destroy_unused' for Tag(id: integer, name: string):Class Do i have to redefin a destroy method in my Posts controller? I'm stumped, any help would be apprecia...

How to do it in Ruby on rails

This is a C# code: byte[] pb = System.Text.Encoding.UTF8.GetBytes(policy.ToString()); // Encode those UTF-8 bytes using Base64 string policyB = Convert.ToBase64String(pb); // Sign the policy with your Secret Key using HMAC SHA-1. System.Security.Cryptography.HMACSHA1 hmac = new System.Security.Cryptography.HMACSHA1(); hmac.Key = Syste...

Ruby on Rails: odd stylesheet issue

When I open up a page that's using my CSS it will work once, but won't work again until you open up the CSS and re-save it. Every other time I try to directly access my CSS, it works fine. But the other times, it doesn't work and I receive this server output: [2010-08-01 12:49:37] ERROR NoMethodError: private method `gsub!' called for #...

How do I install Ruby on Rails?

i have ruby 1.8.6 installed on my machine when i tried gem -v i got gem version 0.9.2 now i do install rails i tried gem install rails ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError) getaddrinfo: no address associated with hostname.(SocketError) why is it so and after installtion where rails is stored. and one th...

RESTful Rails & encapsulating behaviour

Background - I have a model, say Door, that has a state of open or closed. I encapsulate the behaviour of opening the door in a method #open on each instance (And I also have a #close equivalent). But what's the best way to expose this in a RESTful way? What should my route be? It is an UPDATE to Door instance, but what should I UPDATE...

The email body is missing when I send mails with attachements using ActionMailer

The content in the view is not being displayed. Only the attachment is being sent. Help would be appreciated! def send @subject = "Status of PIS App" @recipients = "[email protected]" @from = APP_CONFIG[:email] @sent_on = Time.now #@content_type = "text/html" content_type = "multipart/alternative" attachment :filename => "Report.ht...

what's the difference between mysql 2.8.1 and ruby-mysql 2.9.3

Some plugin works well in mysql gem but doesn't works so well in ruby-mysql in rubygems, mysql gem has 453,540 total downloads, and ruby-mysql only has 12,137 total downloads. I wanna know what's the difference between them. Thanks. ...

tweet this link in rails app

I am surprised I couldn't find it on google, what's the best way to add a "tweet" this link to post a url and a description to the user's twitter account? ...

Ruby On Rails: How to run safe updates

I'm using RoR and I want to do concurrency safe update queries. For example when I have var user = User.find(user_id) user.visits += 1 I get the following SQL code: SELECT * FROM Users WHERE ID=1 -- find user's visits (1) UPDATE Users SET Visits=2 WHERE ID=1 -- 1+1=2 But if there are several queries taking place at the same time, ...

Save object from form to DB

I have a model: class Scr < ActiveRecord::Base def self.find_scrs find(:all, :order => "id") end end View (form): <div class="scr-form"> <fieldset> <% form_for :scr, :url => { :action => :save_scr } do |form| %> <p> <label for="scr_id">Id:</label> <%= form.text_field :id, :size => 40 %> </p> <p> ...

RoR live search

hi iam doing live search function, for this iam using observer_field, but on pageload i get error jquery('#name').delayedObserver is not a function I dont know what is the problem.. ...

best gem for login system

which is the best gem for creating a login system? ...

Which authentication gem/plugin should I use for Rails 3 running on CouchDB?

I'm building a Rails 3 application on CouchDB (using SimplyStored gem) and I'd like to use some existing gem/plugin for authentication, instead of building it from scratch. Problem is, I can't find anything that works smoothly for CouchDB, everything assumes that you're running on ActiveRecord. Do you have any tips? ...

Rails 3.0, want to match 'UK' == 'United Kingdom' in ActiveRecord model

hey I have a problem, I have a Country model. where the entry in the DB is: {:name => 'United Kingdom'} The data I have is UK instead of United Kingdom. in the other models where i search for it i have done: country_name = "United Kingdom" if country.name == "UK" but i have to do this all over the application and that is just bad. S...

Complex rails find ordering

Hi, I am trying to do a find which orders results by their house name and then by the customer's last name. Customer.find(:all, :conditions =>['customers.id IN (?)', intersection], :joins => 'JOIN histories ON histories.customer_id = customers.id JOIN houses ON histories.house_id = houses.id', :order => "houses.name ...

Devise for Ruby on Rails, routing problems after installation

I have rails Rails 2.3.8 and Devise 1.0.8. I have followed the installation instructions, but when trying to access /users/sign_in for the first time after modified routes.rb, I get Internal Server Error undefined method `[]' for :users:Symbol When I reload, I get Routing Error No route matches "/users/sign_up" with {:method=>:get} ...

Prawn PDF and empty database cells?

Hi Everyone, I am using Prawn PDF to create PDF files on the fly in my Rails application. I recently came across the rails cell.blank? function, which has proved to be really handy, I can hide any <li> rows I want if there is nothing to display - something I have been wondering about for a while! Is it possible to do the same in Praw...

Opensource Java or Ruby Web based Virtual Class Room Components ?

Hi All , Is there any ruby or Java Web based Virtual Class Room Components like 1.Whiteboard 2.Instant Messaging 3.Hand Raising Tool 4.Marker Thanks ...

Drag and drop ala GMail a gem for Ruby / Rack?

Is there a widget or a gem which implements this feature? It works only in Chrome and Firefox but it is very cool and no plugins are needed http://gmailblog.blogspot.com/2010/04/drag-and-drop-attachments-onto-messages.html Or which would be the best practises to implement it? ...