How do I close a form_tag? Here's my code:
<%= form_tag :action => 'authenticate' %>
<h1>Already a member?</h1>
<table>
<tr>
<td>Username*: </td>
<td><%= text_field("userform", "user_name", :size => "20", :class => "field") %></td>
</tr>
<tr>
<td>Password*: </td>
<td><%= password_field("userform", "password", :size...
I'm moving a rails app from my desktop to a shared host, and I'm running into trouble with a gem dependency.
I have this declared in my environment.rb:
config.gem "icalendar"
When I first tried starting a console for the app, I got error messages requesting that I rake:install the gem. I used the shared hosting gem install process t...
I have a ruby client program that encrypts a password with string#crypt like so
encrypted = password.crypt(SALT)
# removing first two characters which actually are the salt for safety
return encrypted[2, encrypted.size - 2]
it then sends it to a server for comparison with it's stored pre-encrypted string.
how ever I need to be a...
I am using seeds.rb to populate some State model reference data:
State.create :name => 'Alabama', :abbreviation => 'AL'
State.create :name => 'Alaska', :abbreviation => 'AK'
# ...
Although I am not using state fixtures (since it's seed data to begin with, I think it wouldn't be DRY to have to duplicate this purely for tests), the Rail...
Sorry for this question, apparently all my googling and api searching skills must be failing me. I've written a web crawler in ruby and I'm using Nokogiri::HTML to parse the page. I need to print the page out and while messing around in IRB I noticed a pretty_print method. However it takes a parameter and I can't figure out what it wants...
I am using Rack:Session:Pool for memory based sessions. I would like
to access the pool instance variables that is contacted in
Rack:Session:Pool so I can see all the active session and contained data. How can I do
that from within Sinatra or on the irb prompt.
my initial thought was ::Sinatra:Application::Rack::Session:Pool, but
that s...
Hi,
In the controller, I have an variable @xml_string = "<tag> hello \n world </tag>". Now I want to show the content of @xml_string. In erb file I wrote <%= @xml_string %>, but this can only display hello world, the xml tag <tag> </tag> was missed and \n was ignored.
Aslo , <% render :text => @xml_string , :content_type = 'applicat...
How do I get a list of the folders that exist in a certain directory with ruby?
Dir.entries() looks close but I don't know how to limit to folders only.
...
I have a ruby hash:
VALS = { :one => "One", :two => "Two" }
and an Array:
array2 = ["hello", "world", "One"]
Question: How can I populate a new array1 so that it only pulls in any values in array2 that match exactly the values in VALS?
For example, I have tried:
array2.each_with_index do |e,i|
array1 << e if VALS[i] ~= e
end
Alon...
I can't get the Ruby interpreter to run on either of my Macs (one MacBook and one MacBook Pro, both running Snow Leopard). When I run it, by typing ruby in Terminal, nothing happens. It just sits there. I can kill it by pressing Ctrl+C, but that's it. I know the Ruby process is running, since I can see it in Activity Monitor, and running...
I am trying to populate an array with an intersection of an array and hash based on hash values:
array2 = ["hi","world","One"]
Vals = {:one => "One", :two => "Two"}
array2 = VALS.values & array2
print array2
Works fine for intersection of hash values and array2[ i ], but if I want to instead populate with array2[ i+1 ] element from ar...
Hi,
Is there is any way to specify the width and height of a form when using form_for?
Thanks.
...
I'm working with UTF-8 strings. I need to get a slice using byte-based indexes, not char-based.
I found references on the web to String#subseq, which is supposed to be like String#[], but for bytes. Alas, it seems not to have made it to 1.9.1.
Now, why would I want to do that? There's a chance I'll end up with an invalid string should ...
In Rails, in an initializer/environment.rb Whats the pefered way to detemrine if the webapp itself is being loaded (script/server).
All the initializers are loaded for migrations script/console and other rails task as well, but in my case some stuff only has to be loaded when the server itself is being initialized.
My ideas: checking ...
For Python I use PyCrust, which is a nice graphical shell that feels like a good Java IDE (has autocompletion, inline documentation and can save history).
Is there anything similar for Ruby?
...
I have a string (authenticated, trusted, etc.) containing source code intended to run within a Ruby loop, quickly. In Python, I would compile the string into an abstract syntax tree and eval() or exec() it later:
# Python 3 example
given_code = 'n % 2 == 1'
pred = compile(given_code, '<given>', 'eval')
print("Passed:", [n for n in rang...
I'm trying to convert programatically PDF to HTML. So far I've been using pdftohtml but our users are not happy with the results.
Here's what I need :
I'm using Ruby on Rails, but any tool working on Unix would work as I can call it from the command line. But of course a nice gem or plugin would be perfect.
I'd prefer it to be open s...
Should the following test assert an exception was thrown? On my pc it doesn't and I want to know if this is expected behavior.
def a
raise RuntimeError
end
def b
begin
a
rescue RuntimeError
puts "bummer"
end
end
test "assert this" do
assert_raises RuntimeError do
b
end...
What approach should I take to develop software to block traffic at the desktop level (windows) to sites based on their domain name.
Messing with a host file was easy, but the browser seems to have too long of a delay before it recognizes changes in the host file.
My ideal solution would be a simple ruby script to disable sites during ...
Hi,
how can I view all the available methods on an object in ruby. I'm using the aptana IDE when I type File. no methods are displayed. I'm coming from an eclipse/java background.
Thanks
...