I have a link_to like this:
<%= link_to 'X', category, :confirm => 'Are you sure?', :method => :delete %>
So, I change it like this:
<%=link_to_remote category.name,
:confirm => 'Are you sure?', :method => :delete%>
it show the confirm box, but after I click "yes", it won't delete the item I want , why?
...
Hello,
I struggle to have gems correctly loading in a Snow Leopard environment. I installed ruby and rubygems in '/usr/local' (from http://hivelogic.com/articles/compiling-ruby-rubygems-and-rails-on-snow-leopard/ instructions), I installed some gems with 'gem install gem-name'.
I correctly see the gem list:
$ gem list
*** LOCAL GEMS ...
How to write a piece of code to compare some versions strings and get the newest? For example strings like: 0.1 0.2.1 0.44
...
I'm pretty bad with regex... well I'm learning that is :)
I have the following line (which needs a regex guru's help):
'passenger (2.2.5, 2.0.6)'.match(//)[0]
which obviously doesn't match anything yet
I want to return the just the content of (2.2.5, so everything after the open parentheses and before the comma...
how would I do th...
I'm wondering to what extent I can use associations in Rails. Take into consideration the following:
class User < ActiveRecord::Base
has_one :provider
has_many :businesses, :through => :provider
end
class Provider < ActiveRecord::Base
has_many :businesses
has_many :bids, :through => :businesses
belongs_to :user
end
...
I know you can pass methods the values of which you want to be available to json objects like so:
# user.rb
def name
first_name + last_name
end
# some controller
render :json => @user.to_json(:methods => :name)
But if I want to massage the value returned from the method a bit (with a text helper say) is there a way to do that? I g...
I need to convert an array of integers to a little endian bitmask using Ruby. Any links or hints would be appreciated.
the example says [2,7,9,11] => "4205"
a = [2,7,9,11] # 4205
b = [1,2,3,4] # 0F00
def array_to_mask(arr)
mask = 0
arr.each do |i|
mask = mask | (1 << i)
end
return mask.to_s(16)
end
p array_to_mask(a) # a84
...
i discovered a problem when cron tries to run a ruby script which uses some library.
require "library"
#do some stuff
it complains about not being able to find library.rb
so i was wondering if i could do something like require "/var/dir/library.rb"
...
Trying to install rubyOSA on my iMac
sudo gem install rubyosa
I get the following error:
ERROR: Error installing rubyosa:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framewo...
I have my <%= will_paginate %> code block in the layout of my application. I'd like to pass this block different collections depending on what controller/action I'm in. How can I do this?
...
I posted this to the Cucumber group with no replies, which makes me wonder if this is actually a cucumber issue or not. I'm pretty new to cucumber, and there are a number of things I really don't quite understand about how the cucumber environment is set up and executed within the test environment.
I have a REST API rails app I'm testin...
I want to have a site that is a simple blog so I created a model:
class Post < ActiveRecord::Base
attr_accessible :title, :body
end
I want to use Markdown but without HTML tags. I also want always to keep database clean and my idea is to use before_save()/before_update() callbacks to sanitise my input and escape HTML.
I do...
I have a ruby script I've written using Gruff to produce graphs. These are simple bar charts, and they've worked fine many times. Now, for one particular set of points I'm getting
c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.6/lib/gruff/line.rb:109:in draw': Non-conforming drawing primitive definitionInf' @ draw.c/DrawImage/3140 (Magick::...
Given this code:
has_many :foos, :finder_sql = <<-SQL
select * from foos where bars = #{id}
SQL
The #{id} part is being prematurely interpolated.
How do I escape it?
Thanks.
...
I'm using the Ruby mysql module.
I want to print out the results of a query and include the column names. I'm having trouble finding the method to give me an array of these names. I have the values as shown below.
result = my.query("select * from foo")
result.each do |row| puts row.join(',') end
Thanks for the help!
...
paginate :per_page => per_page, :page => page,
:include => [{:stores => :locations}, :categories, :kosher], :origin => origin,
:conditions => ["products.name LIKE ? #{conditions}", "%#{search}%"],
:within => distance,
:order => sort_order
I am using ruby 1.9.1p243 with Rails 2.3.5 on OSX and this cod...
Is there any way to pass Ruby objects to a C++ application ? I have never done that kind of thing before and was wondering if that would be possible. Would it require to modify the Ruby core code ?
...
I am the intrepid little programmer that could. I began programming rails five weeks ago and I have been stuck on the same error for that entire time. It goes like this. I have mysql application installed, have the latest rails (2.3.5), ruby (1.8.6), and mysql (5.1.40).
I created a perfectly beautiful database and table with content in ...
Hi,
I'm looking for a good book on Ruby which has interesting problems with each chapter that help grasp the fundamental concepts in a good way - something similar to Thinking in Java or Problems in General Physics by IE Irodov.
Any suggestions?
...
While writing a test with a value that gets represented as a BigDecimal, I ran into something weird and decided to dig into it. In brief, '0.00009' when rounded to two decimal places is returned as 0.01 instead of 0.00. Really. Here's my script/console capture:
>> bp = BigDecimal('0.09')
=> #<BigDecimal:210fe08,'0.9E-1',4(8)>
>> bp.ro...