I would like to distribute a rails application as a double clickable application. When someone double clicks on the app, I think that mongrel should be started and then the user's browser should be started and open to something like localhost:3000 I'm trying to work through what I will need to do this, I think I'm going to need to incl...
When a user submits a form and leaves certain fields blank, they get saved as blank in the DB. I would like to iterate through the params[:user] collection (for example) and if a field is blank, set it to nil before updating attributes. I can't figure out how to do this though as the only way I know to iterate creates new objects:
col...
Hi All,
Does anyone have any quality (and up-to-date) information regarding sending mail via Gmail using Ruby's Net::SMTP? I've seen several examples -- most dating from 2007 to mid-2008 and none of them work for me. I need more current examples that use the most recent 1.8.7 release. I'd also appreciate if the documentation didn't o...
I want to make a request to a SOAP Web Service but I don't want to install any gems.
Is there any way to just make the request using plain XML?
I think it's trivial but there might be something I've missed, because all implementations/tutorials were using a gem.
I think that the SOAP response, can be handled also as a XML response rig...
Hello, everyone.
I am trying to install an Amazon Web service gem into my project (I use window and Aptana RadRails) but it asked me to update current Ruby version (1.8.5) to 1.8.7.
I use InstantRails for Window platform. So could you tell me how can I upgrade my Ruby to new version?
Do I need to install new InstantRails? or Can I upd...
class Product < ActiveRecord::Base
set_table_name 'produce'
end
module ActiveRecord
class Base
def self.set_table_name name
define_attr_method :table_name, name
end
def self.define_attr_method(name, value)
singleton_class.send :alias_method, "original_#{name}", name
singleton_class.class_eval do
define_method(name) do
value
en...
lambda is used in this example in both the compose and the hydrate methods. What does lambda do here?
def compose *lambdas
if lambdas.empty?
lambda { nil }
elsif lambdas.size == 1
lambdas.first
else
lambda do |n|
lambdas.first.call(compose(*lambdas[1..-1]).call(n))
end
end
end
def hydrate(modulus, printabl...
I would like to use the ruby on rails and mysql to write a simple test program
but, in this time, i can not update the database record.
because i use the "mid" to replaced the "id" column
in this case, what can i do to work to update the record?
Problem:
Mysql::Error: Unknown column 'id' in 'where clause': UPDATE `messages` SET `messag...
I have a document containing ahref links I want to extract. The link I want can be identified by part of the url they link to. There are other links that are similar which I want to discard.
The urls of the links I want are of the format
http://www.xxxxxxxxxxxxxxxxxxx.com/index.php?showtopic=44&hl=
I want to search for links con...
In our Ruby on Rails project we have a lot of categorization criteria for recipes, such as cook method, occasion etc. Every recipe belongs to one or several of these categories. When someone starts browsing for recipes, he/she can narrow down to a set of particular categories. Then we need to calculate the number of recipes in all catego...
I can't seem to install the twitter gem in my shoes app.
When I try...
Shoes.setup do
gem 'twitter'
end
require 'twitter'
I get
hoe requires RubyGems version >= 1.3.1
Is this a bug in Shoes or Hoe? Any ideas on a work-around?
...
I can't connect mysql db with ruby1.9
OS -> Windows XP SP2
Ruby -> 1.9.1p0
dbi -> 0.4.2
dbd-mysql -> 0.4.3
MySQL API module for Ruby -> 2.7.3
DB(MySQL) -> 5.1.34-community
Because msvcrt-ruby18.dll was not found, I was not able to start this application.
What's wrong
...
I'm trying to set up an Ajax callback using jQuery, and it's just not working. My Ruby code looks something like this:
return {:one => some_html, :two => more_html}.to_json
When it gets to the client jQuery bails saying "parse error". If I make it something really simple, like:
return {:one => 'Something', :two => 'Something else'}.t...
I'm trying to find the "best" way to set default values for objects in rails. Best I can think of is to set the default value in the "new" method in the controller. Anyone have any input on if this is acceptable or if there's a better way to do it?
...
What are the good resource to learn BDD & TDD (ruby , C#, javascript).
What are the good framework using now?
...
I have a partial that I want rendered with a collection and another variable. Is it possible to pass more than one variable to a partial?
To illustrate:
Category HABTM Brands
This is just semi-pseudo-code, but I want to do something like:
<% @categories.each do |c| %>
<%= c.name %>
<%= render :partial => "mypartial", :collec...
Cucumber generates out some neat webrat regex steps. I encountered a problem when I tried the this.
In feature:
And I fill in "Telephone (Home)" with "61234567"
In webrat steps:
When /^I fill in "([^\"]*)" with "([^\"]*)"$/ do |field, value|
fill_in(field, :with => value)
end
The error encountered:
Could not find field: "Telep...
Hi, I have a quick question in Ruby
Lets say I ask the user to enter a name ( for a new class that i want to create)
my code is:
puts "enter the name for a new class that you want to create"
nameofclass = gets.chomp
nameofclass = Class.new
Why does this not work?
Also, I want to ask the user to enter the name of a method that i wan...
How do I check If a Class already exists in Ruby,
My code is:
puts "enter the name of the Class to see if it exists"
nameofclass=gets.chomp
eval (" #{nameofclass}...... Not sure what to write here")
I was thinking of using:
eval "#{nameofclass}ancestors. ....."
...
Quick example: A user enters a username into a form, and I need to make that text username before storing it in the app's database, thereby making it permanently lowercase.
Where would I put this code, and how would I access the data to be lowercased?
Thanks.
...