I decided to use the singleton design pattern while creating a view helper class. This got me thinking; will the singleton instance survive across requests? This led to another question, Which variables (if any) survive across web requests and does that change depending on deployment? (Fastcgi, Mongrel, Passenger, ...)
I know that Con...
I have a Rails app with a jQTouch mobile site that is displayed if the user goes to m.blah.com. First, I detect the browser, then to a redirect_to m.blah.com if it's an iphone, etc. All well and good. When I use desktop Safari, this all works exactly right.
However, when I use an actual iPhone or the Apple iPhone Simulator, it does n...
Hi
I want to call a rake task from a cron job that stores remote weather data in the rails cache. However, I must be doing something pretty wrong here because I cannot find any solution through countless fruitless searches.
Say I define and call this task
namespace :weather do
desc "Store weather from remote source to cache"
task ...
I have a model called HeroStatus with the following attributes:
id
user_id
recordable_type
hero_type (can be NULL!)
recordable_id
created_at
There are over 100 hero_statuses, and a user can have many hero_statuses, but can't have the same hero_status more than once.
A user's hero_status is uniquely identified by the combination of r...
Hi i am using Fusion charts free with Rail 2.3.5
I tried to simulate the single_array example provided in the documentation but instead of graph it is showing me the following message
The method used is setDataXML.The XML is #Creates xml with values for sales data of products #along with their names. #The values required for building t...
I'm trying to build a grid, in rails, for entering data. It has rows and columns, and rows and columns are joined by cells. In my view, I need for the grid to be able to handle having 'new' rows and columns on the edge, so that if you type in them and then submit, they are automatically generated, and their shared cells are connected to ...
Hi i am not able to show up Fusion charts using RoR 2.3.5, just trying to showup the single_series array method for 3d bar graph
Anybody has similar issue ? please help
...
When I visit http://my-application.com/posts/1 in my browser, Rails knows I'm looking for the Post with id = 1. How can I get my application to do this internally? I.e., I'd like a function (call it associate_with_resource) that takes a string containing a URL as its input and outputs the associated resource. For example:
>> associate_w...
I'm using will_paginate for pagination, which has been working well so far, except for this one thing.
If I try to paginate a scope, for instance
class User < ActiveRecord::Base
named_scope :scope, lambda { etc }
end
User.scope.paginate({:page => params[:page], :per_page => 10})
That will tell me paginate is an undefined metho...
As you can see in the current code below, I am finding the duplicate based on the attribute recordable_id. What I need to do is find the duplicate based on four matching attributes: user_id, recordable_type, hero_type, recordable_id. How must I modify the code?
heroes = User.heroes
for hero in heroes
hero_statuses = hero.hero_statuse...
I've been trying to get Rails to play with the new Facebook Graph API. After I get the authorization "code", I need to send another request which returns the access token in JSON form.
It seems to work fine, however I want to fetch the access token JSON without redirecting the user. I'm attempting to use Net::HTTP.get, but I'm not sure ...
I've been trying to solve this problem for a couple of hours but I can't seem to understand what's going on.
I'm using Rails 3 beta, and want to seed some data to the database. However, when I try to seed some values through db:seed, I get this error:
rake aborted!
Attribute(#81402440) expected, got Array(#69024170)
The see...
I just started using RJS which is awesome however I am used to putting visual effects in the link_to_remote and such and I'm not sure how to trigger actions before and after remotes are triggered.
Take this link for example:
HTML
<span id="<%= "edit_comment_link_#{comment.id.to_s}"%>" style="float:left;">
<%= link_to_remote "edit", {...
I currently have three methods which I want to collapse into one:
def send_email(contact,email)
end
def make_call(contact, call)
return link_to "Call", new_contact_call_path(:contact => contact, :call => call, :status => 'called')
end
def make_letter(contact, letter)
return link_to "Letter", new_contact_letter_path(...
When do you use attr_reader/writer/accessor in Rails models?
...
I'm new to rails!
Ok, I am trying to set up a user signup form.
It is mapped as a singular resource in the routes
map.resource :user
And trying to create the user through the console works fine.
the controller code for user's signup is as follows:
def signup
@user = User.new#(params[:user])
end
def create
@user = User.n...
I'm wondering if writing functions like this is considered good or bad form.
def test(x)
if x == 1
return true
else
return "Error: x is not equal to one."
end
end
And then to use it we do something like this:
result = test(1)
if result != true
puts result
end
result = test(2)
if result != true
p...
Hi,
i have configured to use authlogic and declarative_authorization and configured authorization_rules.rb. All is fine but on attemp to access localhost/authorization_rules i see "You are not allowed to access this action.". I've added
has_permission_on :authorization_rules, :to => [:index, :show]
but nothing changed :( In logs i se...
Hello, so I have this big method in my application for newsletter distribution. Method is for updating rayons and I need to assign a user to rayon. I have relation n:n through table colporteur_in_rayons which has attributes since_date and until_date.
I am a junior programmer and I know this code is pretty dummy :)
I appreciate every s...
I have a rails webapp which internally connects to another request server. At times , ruby process gets stuck in close_wait state and stop responding and needs a restart. i guess this happens only when the request server which the rails app connects to is restarted. But am not completely sure of it. Any help appreciated on how should i g...