Hi,
I have a quite long method. It copy an ActiveRecord object with all relations, and changes relations in some cases. To make code more readable, I use private methods. I would like to test them. Technicaly, in Ruby it is no problem, but I suspect, I have bad design. Do you have any advices how to deal with such case?
...
Hello,
I have this method (50+ lines) in one of my models, I prefer not having to scroll so much and not losing my cursor sometimes because of its taking up so much space. I wonder if I can put it away in a separate file and sort of include it in the model instead.
Thanks!
...
Hi,
I have a requirement where a screen allows and end user to create a filter that is basically any valid sql fragment. For reasons beyond my control this is what is needed so I need to work within this boundary.
This sql fragment gets appended to a where clause in a sql statement.Currently to avoid anything to nasty going on the log...
I have some classes in the lib directory, and I want to test it. My class which I want to test looks like:
class StatAggregation
class << self
def skills_rate(user_id)
user_id = User.find_by_id(user_id)
...
end
end
end
I created spec:
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
des...
Hi,
Today I implemented a small piece of code that include analytics only in production environment using something like:
<% if Rails.env.production? %>
analytics here
<% end %>
I don't see anything wrong about it... however one of my c0-workers told me that it wasn't a good practice at all, that it would for sure introduce proble...
I need to have one table in which i can set user preferences I want to have one table in which all preferences values are set and another relation table in which i will have user_id and the preference_id but I need to have preference for three different pages
item
favorite
recent.
I need to show the list of results as set by user...
Hi,
When I call the action, the action should open up the thick box with the value.
So for that I have used something like thing, but it didn't work
def call
render :action=>"call_page", :class=>"thickbox"
end
and also used
def call
render :partial=>"call_page", :class=>"thickbox"
end
so, please tell me how I can go with this...
I have a few places in a model that does stuff like
def ServerInfo.starttime(param)
find(:all, :conditions => "name ='#{param}_started'", :select => "date").first.date.to_datetime
end
Now, for reasons not relevant to the question, it can happen that this particular row is not in the database at all and the code above fails wit...
I have a signup form, and I wanted to make it so that they have the option of recommending this signup to all their friends in facebook.
Is there a rails API/gem for doing this?
Is there an appropriate name for this?
Thanks!
...
NoMethodError in ContainerformatsController#create
undefined method `yuvstreams' for #
hi all,
i am getting this error i don't no what happened ,its working
fine
few days before but it not working this is code for create function
@containerformat = Containerformat.new(params[:containerformat])
if @containerformat.containerFm...
Hi there,
atm i'm trying to create a AMF request to a rails backend. I allready successfuly implemented the AMF communication, but i still got some problems with the custom functions i'm using.
I created a function to request the server if a property in my SQL DB exists, the server return a boolean.
In my flexapp the function looks lik...
Here is my case:
I want to use a web browser to connect to a Rails application that runs this example code on the server side:
Dir.chdir path_typed_in_by_user
system "ls -la"
I want the output of "ls -la" to be displayed on the web browser.
Is this possible somehow?
...
Here's the scenario of out of the box map.resources
I'm on /users/new
Submit -> /users/
rescue error render new
URL: is /users/
If User.index never defined.
I copy the URL to another tab, it'll have routing error.
How can I have the URL showing /users/new while activerecord errors persists on the page?
...
I'm trying to use delayed_job to send emails from an input form. In my view i have replaced the line
Emailer.deliver_signup(@usercontact)
with
Emailer.send_later(:deliver_signup, @usercontact)
but when i run the job with rake jobs:work, i get: undefined method 'deliver_signup' for "CLASS:Emailer":String
What am I doing wrong? (N...
I am new to Ruby-on-rails and need to be able to build a Rake file that will connect to a corporate data source and then use the data to update a table in SQLite3.
Is that possible? Should I be using a rake file?
I would eventually want to use a timer to run an update on a daily basis.
...
It used to be that the ruby on rails guides for version 3.0 were at http://edgeguides.rubyonrails.org/ and the guides for version 2.3 were at http://guides.rubyonrails.org . Now that version 3 has been released, its guides have been moved to the main URL.
Is there any way to access the guides for rails 2.3?
...
I am using respond_with and everything is hooked up right to get data correctly. I want to customize the returned json, xml and foobar formats in a DRY way, but I cannot figure out how to do so using the limited :only and :include. These are great when the data is simple, but with complex finds, they fall short of what I want.
Lets say...
Maximum(:created_at) does not give the timestamp in local time format but in UTC.
I am using Rails 2.3.8
Is there another way to get the latest created_at in local time?
...
I get the following error:
Delayed::Job SomeMailJob# (NoMethodError) "undefined method `subject' for #<YAML::Object:0x2b0a191f4c78>"
This comes from the following code which references the SombMailJob above:
class SomeMailJob < Struct.new(:contact, :contact_email)
def perform
OutboundMailer.deliver_campaign_email(contact,co...
i'm a .net guy doing some work/learning RoR. i have a handful of environment-specific settings i'd like to externalize (s3 access info). what is the way to do this? I realize the place for it is in config/environment/[environment], but i'm asking beyond that. Should it be a global constant? should i use an initializer? how do i cleanly m...