I'm using JQuery to post in a Sinatra application.
$.post("/addnewlistitem", $('#inputrow1').val(), function(data){alert(data);});
Haml looks like this:
%input{:type => "text", :id => "inputrow1", :name => "item", :class => "txt"}
And the ruby code, like this:
post '/addnewlistitem' do
@v = params[:item]
end
The problem is ...
I am using Hash#to_xml in my Sinatra application. It did work till I moved to actviesupport 3.0.0
Is there a difference in usage of activesupport in 3.0.0?
For example this works fine
gem 'activesupport', '2.3.5'
require 'active_support'
{}.to_xml
and
gem 'activesupport', '3.0.0'
require 'active_support'
{}.to_xml
generates: N...
I need to pass a collection to the standard select input in Formtastic:
f.input :apple, :as => :select, :collection => Apple.all
The problem is, though that I need Formtastic to access a different method than name. Now this is really a problem. I can always pass the Array
f.input :apple, :as => :select, :collection => Apple.map { |a|...
Hi all,
I had to rebuild my box and I currently am unable to install Watir.
gem install watir
ERROR: Error installing watir:
activesupport requires Ruby version >= 1.8.7.
Which would be fine if Watir was able to use Ruby 1.8.7 . I am using
ruby -v
ruby 1.8.6 (2008-08-11 patchlevel 287) [i386-mswin32]
ge...
I'm a bit confused about how paths work with gems. Here's the core of my confusion:
>> require 'rubygems'
=> false
>> Gem.available?('money')
=> true
>> require 'money'
LoadError: no such file to load -- money
from (irb):3:in `require'
from (irb):3
from /usr/bin/irb:12:in `<main>'
>> Gem.available?('pony')
=> fa...
I'm executing a rake script that calls a powershell function. The function returns a value, how can i get this value and provide it to my rake template file?
Thanks for any suggestions
...
When I try to update rubygems (by running 'gem update --system') I get this error:
ERROR: While executing gem ... (RuntimeError)
gem update --system is disabled on Debian. RubyGems can be updated using the official Debian repositories by aptitude or apt-get.
Any idea what might be wrong and how I can fix it?
...
Whenever I install gems I see ri and rdoc follow. I know this is documentation but what is the difference between the two and how to use them?
...
I am new to programming.. I was thinking to start learning with Ruby or Python. y main task would be web development. But I cannot choose between them. Which language do you think I should learn?
...
Hi guys,
I've just started playing with Ruby Version Manager (http://rvm.beginrescueend.com/rvm/cli/).
I have succefully configured rvm to use ruby 1.9.2 and everythin is fine.
However when I'm trying to do something using sudo no rvm or installed ruby is detected
administrator@hosting-live-2:~$ ruby -v
ruby 1.9.2p0 (2010-08-18 revis...
Is there any standard way to avoid truthiness in Ruby, or would I need to roll my own solution, such as
class FalseClass
def to_bool
self
end
end
class TrueClass
def to_bool
self
end
end
true.to_bool # => true
false.to_bool # => false
nil.to_bool # => NoMethodError
42.to_bool # => NoMethodError
Background: I know tha...
In RSpec, if I have warnings on and have
x.should == 42
another_line_of_code
then I get a warning about
warning: useless use of == in void context
Is there anything I can do other than
Turn warnings off
Change it to bitbucket = (x.should == 42)
...
Hi Everyone,
I have the following if statement in my view:
<% if @kase.jobno[1,2].to_i == 10 then %>
<img src="../images/2010.jpg" alt="2010">
<% elsif @kase.jobno[1,2].to_i == 11 then %>
<img src="../images/2011.jpg" alt="2011">
<% else %>
<img src="../images/document.jpg" alt="Document" />
<% end %>
It works absolutely perfe...
What HBase ORM/adapters for Ruby exists? Which are the best? WHY?
...
Hello,
Im new to Ruby On Rails.Im using Ruby version 1.8.7 and Rails version 2.3.8.I created a controller SayHello using
ruby script/generate controller SayHello
The application works as expected, but i cant find the application.rb file. Where is the application.rb file located ?
Please Help
Thank You
...
In my Gemfile in Rails I have these groups:
group :development, :test do
gem "capybara"
gem "database_cleaner"
gem "spork"
gem "launchy"
end
group :bdd do
gem "cucumber-rails"
gem "rspec-rails"
end
What does this mean?
...
s = "你好"
s.encoding # => #<Encoding:UTF-8>
yaml = s.to_yaml # => "--- \"\\xE4\\xBD\\xA0\\xE5\\xA5\\xBD\"\n"
yaml.encoding # => #<Encoding:ASCII-8BIT>
yaml.force_encoding 'utf-8' # => "--- \"\\xE4\\xBD\\xA0\\xE5\\xA5\\xBD\"\n"
Then, how to make the 'to_yaml' generate original looking: "你好", I mean not something ...
I'm using the Thor gem, but I have cloned the git repo to a folder and I want the system to use that one instead and not the gem, because I have added a feature in the cloned repo and want to test it.
How do I tell the system (Ubuntu 10.4) to use the cloned repo and not the installed gem.
...
I'm implementing Factory Girl as a replacement for fixtures in my Rails app. I have several tables that I'm trying to represent using associations. However, to throw a kink into the loop, beyond just defining the associations, I also need to access attributes of the child factories from the parent.
Below is an example of what I'm tryi...
I have been attempting to learn tcp/udp for so long now, I am on the brink of giving up completely and never attempting it again, I have read every tutorial there is but can never get anything to work. Tutorials either stop once they tell me how to connect and dont explain how it can be used or do not provide enough source code. Is there...