ruby-on-rails

Where is that modified version rails3 running on macruby?

http://www.macruby.org/blog/2010/04/30/macruby06.html In MacRuby blog. They said that: This release also passes about 85% of RubySpecs, is able to run a modified version of Rails 3, and implements better support for Ruby 1.9 encodings. How can I get that modified version rails3? Google cannot give me answer. ...

About tlsmail with rails = Error - 'no such file to load -- tlsmail.'

I have configured smtp gmail for mail sending. It sends mail well, but when try to open script/console, it says no such file to load -- tlsmail and ends. If i comment out the require 'tlsmail' file in environment.rb file, it doesn't send the mail. gem list also shows the tlsmail installed on machine. ...

Removing bold characters from Bing JSON results

This is being returned from Bing's JSON API: "ÓÄÄTestÓÄÅ.com Web Based ÓÄÄTestingÓÄÅ and Certification Software v2.0" This is because "test" was the search keyword and is supposed to be replaced with strong or bold tags. I want to take this out, but I can't seem to use gsub or delete as they in unicode (I'm not even sure if it is unic...

Clear page cache in Rails

How can I clear a page cache. I tried impelemnting cache but switched it off, now my home page always loads the cached version. I tried the following rake task no luck. namespace :cache_clear do desc 'clear a page cache' task :expire_cache => :environment do ActionController::Base::expire_page('/') puts "Cache cl...

Associations in ActionMailer Template

I have an ActionMailer Model (Notifier) and a view for the mail. In my controller i build an Array (access_data) that looks like this: access_data = [] users.each do |user| access_data << {'subscriptions' => user.subscriptions, 'login' => user.login} end When i create a "normal" view, i can do this: <% access_data['subscriptions']....

Server calls happening twice

I am using ruby on rails at back & javascript on front end to communicate. I am using $.post() / $.getJSON & both of these calls are happening twice ! I am seeing logs of two different calls in server & if I print something in callback function , its printed twice as well. I am pretty sure its nothing due to my code as even simplistic r...

RSpec: testing path to route mapping (but not the other way around)

Hello, I need to use the functionality of params_from, which was deprecated. Now route_to combines behavior of params_from and route_for. But I do not want to test that the route generates the path, because it does not and this is intentional (for backward compatability in old emails, I need to "alias" old path to the correct controller...

Why I got a unknown action??

I have a "manageUser" page, the route is like that: map.manageUsers "manageUsers", :controller => "users", :action => "manageUsers" and, it like a index of user, but provide a ban button for admin to ban the user, so, I have something like this: <% @users.each do |user| %> <td><%=h user.username %></td> <td><%= link_t...

MongoId and bson_ext problem: no such file to load -- bson_ext

There is a similar question about 'bson_ext', but it's not work for me. http://stackoverflow.com/questions/2900604/mongomapper-and-bson-ext-problem I'm using Rails 2.3.8 + MongoId 1.9.1. I followed the "installation" page as: gem install mongoid gem install mongo -v=1.0.4 gem install bson_ext -v=1.0.4 In my config/environment.rb, I ...

Can I limit the method in Ruby on Rails is POST method only?

For example: class UsersController < ApplicationController def doSomething end def doSomethingAgain end end Can I restrict the user pass a get method only to doSomething, but doSomethingAgain is only accept post method, can I do so? ...

Is it possible to read, using open graph, on a server side if user is logged in to facebook ?

Someone is logged in to Facebook and than goes to my website. Is it possible to read on a server side if he's logged in to facebook now. I need to show different fields for a comment form. At the moment I'm using Rails and http://github.com/jugend/fgraph plugin ...

How should we test an rjs response in Rails Functional tests ?

How can I test a .js.rjs response in rails(2.3.8) functional test ? ...

How to give focus property to text box in Ruby on Rails?

I have a problem with setting the focus to the textbox for a login page in Ruby on Rails. I want to give focus to a user text field. Is there any way to give focus property to text_field? ...

Passing a variable into a models after_initialize method

I have the following (heavily simplified) model, that uses will_paginate class Search < ActiveRecord::Base attr_reader :articles def after_initialize @articles = Article.paginate_by_name name, :page => 1 end end and the controller code in my show action is @search = Search.new(params[:search]) This all works fine, but ...

Set a hash to a Array field in MongoId, no error?

I'm using MongoId 1.9.1, I defined a class like following: class P include Mongoid::Document field :s, :type=>Array end We can see, the type of field 's' is String, but: p = P.new p.s = {:a=>1, :b=>2} p.save() It's saved with no error! And can be queried: >> P.find(:last) => #<P _id: 4c3f0159e138231105000006, x: nil, s: {"b"=>...

Paperclip ":discard_if" functionality

Hi there, I'm using Paperclip and accepts_nested_attributes for. I'm wondering what is the best way to discard photos (i.e. not save them in the db), if they have {model}_file_size == nil. This could be done using attribute_fu like in the example bellow, using the discard_if option. The Photo class uses Paperclip. However, I don't want ...

Ruby on Rails: how do I set a variable where the variable being changed can change?

i want to do current_user.allow_????? = true where ????? could be whatever I wanted it to be I've seen it done before.. just don't remember where, or what the thing is called. ...

Customizing attachment_fu?

I am working with the attachment_fu plugin for my file uploads, while it does some things very well I am finding it very difficult to customize. One of the problems I am having is that the errors messages attachment_fu produces are not very helpful to the end user. For instance, if you do not specify a file to upload you all of these err...

Ruby on Rails: How do I set a variable to a constant, where part of the name of the constant can change?

I want to do current_user.field = User::????????? Where ?????????? would be whatever I wanted it to be This what I'm trying to do Given /^"([^\"]*)" is a(?:|n) "([^\"]*)"$/ do |arg1, arg2| cur_user = User.find(:first, :conditions => ['name = ?', arg1]) cur_user.update_attributes(:role => User::arg2.constantize) end While const...

Rails: Paper Clip Cropping Syntax

What is the difference between using > or # when cropping a thumb: example: has_attached_file :image, :styles => {:small => "100x100#"} has_attached_file :image, :styles => {:small => "100x100>"} How do get a thumb that has the maxium height of 100px but variable width (to preserve the aspect ratio)? Thanks Deb ...