so i am trying to extract the email of my website using ruby mechanize and hpricot.
what i a trying to do its loop on all the page of my administration side and parse the pages with hpricot.so far so good. Then I get:
Exception `Net::HTTPBadResponse' at /usr/lib/ruby/1.8/net/http.rb:2022 - wrong status line: *SOME HTML CODE HERE*
wh...
I'm new to rails and can't figure out this issue...
I have a controller
Admin::Blog::EntriesController
defined in app/controllers/admin/blog/entries_controller.rb
And I have a model called
Blog::Entry
defined in app/model/blog/entry.rb
When I try to access my model from the controller, I get a "uninitialized constant Admin::Blog...
I'm attempting to use rspec in a rails project I've just upgraded to rails 2.3.2. I've installed rspec 1.2.6 and rspec-rails 1.2.6 as plugins in the app.
My problem is the specs don't have access to my app classes or any of the rails standard libraries.
First I had to specify the model class I want to test by using the full path from R...
Hi,
This might be a simple prob. But I am new to rails. I am trying to convert a string value into a name of an attribute that belongs to an object. For example, in the following code, I need all the string values in the column_array turned into attribute names. "student_identification" , "email".. all these are actual column names o...
My apologies if this has been answered before or is obvious...did some searching here and on the Goog and couldn't find an answer.
I'm looking to sort an array of Providers by price and whether they are a preferred_provider? (true or false)
For instance in array p of Providers...
p1.price == 1, p1.preferred_provider? == false
p2.price...
I'm currently learning Ruby and RoR and I stumbled across this declaration:
link_to_remote(name, options = {}, html_options = nil)
I discovered that this pattern is used on several other Rails functions.
Why are the default values defined that way? Why not one of these two?
... options = {}, html_options = {})
... options = nil, h...
I have body:text content:text sender_id:integer receiver_id:integer in message table
I have this in user model:
has_many :sent_messages, :class_name => "Message", :foreign_key => "sender_id"
has_many :received_messages, :class_name => "Message", :foreign_key => "receiver_id"
I have this in message model:
belongs_to :sender...
I'm looking for a way to dump the structure of an object, similar to the PHP functions print_r and var_dump for debugging reasons.
...
In Ruby on Rails, I sometimes get an error on the page as:
compile error
/Users/jian/ror/shov2/app/views/stories/index.html.erb:13:
syntax error, unexpected kENSURE,
expecting ')'
/Users/jian/ror/shov2/app/views/stories/index.html.erb:15:
syntax error, unexpected kEND,
expecting ')'
the kEND, i can guess that it is End....
there is a line displayed within <pre>
<%= h @stories.inspect %>
and the output was too long, so i changed it to
<%= #h @stories.inspect %>
<% @stories.each do |s| %>
<%= h s.inspect %>
<% end %>
(commenting out the first line). now the code will fail to compile... saying
compile error
/Users/winterheat/ror/shov2/app/views/sto...
OK. This is insane.
I'm new to RoR and I really want to get into it as everything about it that I have seen so far makes it more appealing to the type of work that I do.
However, I can't seem to accomplish a very simple thing with RoR.
I want these controlers:
/admin/blog/entries (index/show/edit/delete)
/admin/blog/categories (index...
I'm getting started building a site with Rails and I would like people to be able to vote certain things with the options of "yes" or "no" or "right" or "wrong". I would also like there to be a running tally computed by percent (maybe below). Could someone tell me how I can add this functionality?
Thanks
...
I'm trying to make a helper which automatically picks the correct partial based on the types of objects returned by either ActiveRecord::Base#find or an association. Unfortuneatly I can't just look at the first element of the returned array because I want to pick the correct one in this case as well. If you call an association, it return...
Hi,
I'm using a rails plugin call acts_as_translatable. The plugin modify the sql sent to the DB to enable multiple translation a the model level.
The plugin works good with SELECT statement, through the override of the ActiveRecord::Base::construc_finder_sql method. However, it does not work for update statements. I am tring to fix i...
In Ruby on rails, our model includes orders and payments.
There's 1-many relationship between order and payments.
In the orders model we specify:
*has_many :payments, :as => :payable*
And a payment record has payable_id that is set to order.id.
In a report, I want to select all payments that belong to orders of a given type.
Using:
...
I am using Rails and jquery with RJS templates to perform various AJAX requests.
For most of my Ajax stuff I attach a submit handler to the form in my application.js as follows:
$('#tagging_flickr_photos').submitWithAjax();
$('#tag_submit').click(function() {
$('#flickr-photos-status').show();
});
This calls the form action whic...
I would like to get file version info for executable files on Windows with Ruby.
Is there a way to do that?
...
I am refactoring some code that I did not write, and I found a line that looks like this (it is much longer, i used just a little bit for this example):
system("rubyw -e \"require 'win32ole'; @autoit=WIN32OLE.new('AutoItX3.Control');")
To increase readability, I refactored it to
do_something =
"rubyw -e \"
require 'win32ole'
...
I have a feeling I'm just doing something wrong syntactically but it's surprisingly difficult to Google "GET" so I was hoping someone here might know the answer to this.
I'm trying to test a Rails controller from an RSpec test. I'm following an example I found here - http://www.elevatedrails.com/articles/2007/09/10/testing-controllers-...
I have the following ActiveRecords
class Product < ActiveRecord::Base
has_many :reviews
end
class Review < ActiveRecord::Base
belongs_to :product
end
Each review object contains a field named 'rating'
I wish to get a list of all products whose average rating is larger than a specific bound.
I don't understand how to us...