I am planning a web-based commercial application with front-end RoR and back-end PostgreSQL.
I've some confusion about RoR and PostgreSQL Edition to use. For RoR, I have Aptana RADRails installed. For PostgreSQL, a free variant is also available at EnterpriseDB.
Previously I installed a free EnterpriseDB PostgreSQL variant and it was v...
How can I declare a method with keyword arguments just like rails do. some examples may be
Person.find(:all, :conditions => "...").
How can I use symbols to create methods similar to the above?
I am very new to ruby. Thanks in advance!
...
I have a method which takes a code block.
def opportunity
@opportunities += 1
if yield
@performances +=1
end
end
and I call it like this:
opportunity { @some_array.empty? }
But how do I pass it more than one code block so that I could use yield twice, something like this:
def opportunity
if yield_1
...
In Ruby I'm looking to read data until I reach a delimiter or end of file. I found this is possible by redefining $/ or the $INPUT_RECORD_SEPARATOR to my delimiter. However with all the "features" in the Ruby language it seems hokey to change the value of a global to do this. Also, readline used to consume the delimiter while not it is ...
Hi
I want to add "Sharing documents" feature to my app, like in google documents service. As i see:
User can:
can list/view/create/edit/delete own documents
share own document to everyone - its a public document
share own document to another user with read-only access
share own document to another user with read-write access
view li...
How can I get rid of validation messages telling me that:
Login is too short (minimum is 3 characters)
Login should use only letters, numbers, spaces, and .-_@ please.
Password is too short (minimum is 4 characters)
Password confirmation is too short (minimum is 4 characters)
this happens even before map_openid_registration is called,...
I'm trying to parse a text file that has ANSI color sequences in it, e.g.
\e[0;37m
How can I build a regex to match this in Ruby?
...
I need to strip out all font tags from a document. When attempting to do so with the following Ruby code, other elements and text within the font tags are lost. I've also attempted to iterate through all children elements and make them siblings of the font tag before unlinking the font tag--which also results in lost HTML. What is a g...
given an xml string like this:
<some><nested><xml>value</xml></nested></some>
what's the best option (using ruby) to format it into something readable like:
<some>
<nested>
<xml>value</xml>
</nested>
</some>
...
In every benchmark that I found on the web it seems that Ruby is slow, much slower than Java. The Ruby folks just state that it doesn't matter. Could you give me any example that the speed of Ruby on Rails (and the Ruby itself) really doesn't matter?
...
Remember iwantsandy.com? It was quite popular for what it did. ANyways, I'm looking to do something similar, but my question is, how does one process incoming emails? Let's assuming I'm using PHP or maybe even Ruby to do this. I would need a way to process the emails and dump them into a DB or something. Ok fine, but my main question is ...
My problem is a bit hairy, and I may be asking the wrong questions, so please bear with me...
I have a legacy MySQL database which stores the user passwords & salts for a membership system. Both of these values have been hashed using the Ruby framework - roughly like this:
hashedsalt =
Digest::SHA1.hexdigest("--#{Time.now.to_s}--...
I have three models that look something like this:
class Bucket < ActiveRecord::Base
has_many :entries
end
class Entry < ActiveRecord::Base
belongs_to :submission
belongs_to :bucket
end
class Submission < ActiveRecord::Base
has_many :entries
belongs_to :user
end
class User < ActiveRecord::Base
has_many :submissions
end
...
hello,
i have this crazy label for each time i create a migration that use the time instead of a integer. it makes things very hard to switch between the version of the database that you want to use.
i also have this crazy ID for each object that i create :
How can set up rails to have easy version and id numbers.
thank you
...
I can change the irb prompt mode with
irb --prompt prompt-mode
I can see what null and simple does, but I can't tell the difference between null and xmp and the difference between default/classic/inf-ruby. Can someone explain to me what these other modes do? It seems pointless to have multiple modes doing the same thing.
...
How do i override/set authlogic to use the email field instead of the username field for both signup and authentication, having a username + an email is occasionally too intense for some some registration scenarios
...
t = Time.now
d = 10.minutes.from_now
Using these two variables, how do I output a timer like 00:10:00?
As d counts down, the timer would show 00:09:59, 00:09:58, etc.
Note: I'd formatting uses Rails datetime format method somehow.
...
In tag#show I list all entries with that tag. At the bottom of the page I'd like to have something like: "Related Tags: linked, list, of, related tags" My view looks like:
<h2><%= link_to 'Tag', tags_path %>: <%= @tag.name.titleize %></h2>
<% @entries.each do |entry| %>
<h2><%= link_to h(entry.name), entry %></h2>
<%- unless entry...
Pony is broken in ruby 1.9. Does any recommend any alternatives for me so I can send mail through my Gmail account? Cheers
...
This is what I'm trying to do:
def call_block(in_class = "String", &block)
instance = eval("#{in_class}.new")
puts "instance class: #{instance.class}"
instance.instance_eval{ block.call }
end
# --- TEST EXAMPLE ---
# This outputs "class: String" every time
"sdlkfj".instance_eval { puts "class: #{self.class}" }
# This wil...