I am consuming various XML-over-HTTP web services returning large XML files (> 2MB). What would be the fastest ruby http library to reduce the 'downloading' time?
Required features:
both GET and POST requests
gzip/deflate downloads (Accept-Encoding: deflate, gzip) - very important
I am thinking between:
open-uri
Net::HTTP
curb
b...
I feel like I'm just missing an environmental variable here, but is there anyway to get the FQDN and port that a Rails server is listening on? I feel like there should be a variable like RAILS_URL or something. I'd like to access it from a model.
...
I'm attempting to use the Super Inplace Controls plugin, which has an in_place_select method. I have the following models:
class Incident < ActiveRecord::Base
belongs_to :incident_status
validates_existence_of :incident_status
end
class IncidentStatus < ActiveRecord::Base
has_many :incidents
end
Right now, Incide...
Hi guys,
There is a massive database (GB) that I am working with now and all of the previous development has been done on a slicehost slice. I am trying to get ready for more developers to come in and work so I need each person to be able to setup his own machine for development, which means potentially copying this database. Selecting ...
MODEL:
class Listing < ActiveRecord::Base
serialize :details
validates_presence_of :name, :details
end
VIEW:
<% form_for(@listing) do |f| %>
<div class="text_field">
<%= f.label :name, "Name" %><br />
<%= f.text_field :name, :autocomplete => "off" %>
</div>
<!-- CUSTOM DETAILS HERE! -->
<% end %>
...
I am using the code:
<%= image_tag site.photo.url(:small) if site.photo.file? %>
to tell my app to display nothing if there is no photo associated with a particular post (site in this case). Is there a way to render a message along w/ this. For instance "no image with the post". I tried simply doing
<%= if site.photo.file? %>
<p> n...
Is it possible to start an AMQP subscriber with my Rails app? Possibly through an initializer or something.
I'd like to have it running at the same time that can also interact with Rails models. Below is a pseudo-code example of what I mean.
queue.subscribe do |msg,body|
Foo.create(....)
end
...
I'm a little confused as to the mechanics of eager loading in active record. Lets say a Book model has many Pages and I fetch a book using this query:
@book = Book.find book_id, :include => :pages
Now this where I'm confused. My understanding is that @book.pages is already loaded and won't execute another query. But suppose I want to ...
Hi all,
I have a bunch of images in SVN I would like to move out and put on S3. How have you dealt with keeping images out of your ruby on rails apps and out of SVN?
...
I have the following (snipped) parameters passed into my controller.
Parameters: {"commit"=>"OK", "action"=>"set_incident_incident_status_id", "id"=>"1", "controller"=>"incidents", "incident"=>{"incident_status_id"=>"1"}}
I know that if I want to select the incident, I can do:
@incident = Incident.find(params[:id])
How do I access ...
I have a scenario where I am going to be creating a large number of models that use STI and I'm wondering what the best way to organize this is. I already have other models using STI and I really do not want to add any more files to my models folder. Is there any way to create a folder and add the models using STI there (there could be...
Rails adds a humanize() method for strings that works as follows (from the Rails RDoc):
"employee_salary".humanize # => "Employee salary"
"author_id".humanize # => "Author"
I want to go the other way. I have "pretty" input from a user that I want to 'de-humanize' for writing to a model's attribute:
"Employee salary" # =>...
The idea would be to have one en.yml file for formtastic labels, one for hints, one for other I18n-Translations. Is that possible?
...
I am trying to execute a powershell script from Ruby, I have entered the below command:
scriptPath = system('powershell \"C:\\Scripts\\DB_Setup.ps1\"')
The ruby Script is handling exceptions when an error is raised to stop the script as below command:
rescue => ex
message = "\nscript on server '#{`hostname`.strip()}' terminated u...
I have the parent class in
/dir1/test1.rb
then i have the child class in
/dir2/test2.rb
the test1 class has a method that uses the "File.dirname(FILE)".
BUT when i call this method from the test2, that inherent from test1
the dir is the dir1, insted the dir2, where the test2 is.
How to make it work?
...
Does to_json require parameters? what about within rails?
I started getting the error "wrong number of arguments (0 for 1)" when doing myhash.to_json
Unfortunately I'm not sure when this error started happening, but I guess it relates to some versions of either rails or the json gem. I suppose my code (in a rails controller) is using t...
I have a model User that has_one user_profile and a User_Profile belongs_to user
in the User controller I have:
def personal
@user = User.find_by_id(params[:id])
@user_profile = @user.user_profile
@user_profile ||= @user.build_user_profile
end
def update_personal
@user = User.find_by_id(params[:id])
if @user....
I have a rails 3 application and a file with some Russian characters in it:
# lib/foo.rb
@foo = 'Привет'
When I try to load this file in rails console, the following error occures:
c:\railsapp>rails console
Loading development environment (Rails 3.0.0.beta2)
irb(main):001:0> require 'foo'
SyntaxError: c:/railsapp/lib/foo.rb:...
Right now I cant find a way to generate a callback between lines 1 and 2 here:
f = Foo.new
f.some_call
f.save!
Is there any way to simulate what would be effectively an after_new callback? Right now I'm using after_initialize but there are potential performance problems with using that since it fires for a lot of different events.
...
Hi All
I am having a problem in RSpec when my mock object is asked for a URL by the ActionController. The URL is a Mock one and not a correct resource URL.
I am running RSpec 1.3.0 and Rails 2.3.5
Basically I have two models. Where a subject has many notes.
class Subject < ActiveRecord::Base
validates_presence_of :title
has_many...