I have a order object, which have a create method like this :
def create
@order = Order.new(params[:order])
# @order.status_id = "1"
respond_to do |format|
if @order.save
flash[:notice] = 'Order was successfully created.'
format.html { redirect_to(@order) }
...
Given a URL, I would like to be able to render the returned HTML to know width and height for each div, fonts' size for each piece of text, color of each element, position of each element on screen, etc.
A possible approach could be traversing the DOM tree with Hpricot and checking CSS style by parsing the associated stylesheet using cs...
I'm trying to connect to yahoo via oauth. I'm using the oauth gem with ruby.
I can successfully get an access token, but then I'm no able to use it to make any call. Here's my code:
def oauth
OAuth::Consumer.new(ApplicationConfig['yahoo']['access_token'],
ApplicationConfig['yahoo']['secret'],
{
:site ...
I have the following attribute in an xml node I'm reading with libxml. It prints out normally with the accented character if I print out reader.node.
reader = XML::Reader.new(File.open("somefile.xml", "r"))
reader.read
reader.read
...
p reader.node
=> ... Full_Name="Univisión Network - East Feed" ...
If I do this, though, it comes o...
Edit: To be clear, I'm trying to use this kind of generator (i.e. with a 'yield' statement) not a Rails generator.
I have the following (simplified) initializer mixin in a Rails project that I could use some help with. What I wanted to do was create a generator to track Twitter API calls (this is just for debugging, I know about rate_li...
is possible to use ruby 1.9 with rails 2.3?
thanks
...
I have a Ruby application (not using Rails) that use my own Ruby gems. I have these gems hosted on a local gem repository server. Some of these gems have dependencies on other publicly available gems from gemcutter (ex: haml, curb).
Would it make sense to vendor/mirror these publicly available gems on my local gem server so that I would...
I would like to take out a parameter from url by it's name without knowing if it is the first, middle or last parameter and reassemble url again. I guess it is not that hard to write something on my own using CGI or URI, but I imagine such functionality exists already. Any suggestions?
in:
http://example.com/path?param1=one&param2=...
If a is the array, I want a.index(a.max), but something more Ruby-like. It should be obvious, but I'm having trouble finding the answer at so and elsewhere. Obviously, I am new to Ruby.
Cary
...
# Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec
rentable_items = [
%w(x x x - - - x x x - - -), # item1
%w(- - - - - - - - - - - -), # item2
%w(x x x x x x x - - - - -), # item3
%w(x x x - - - - x x x x x) ]# item4
Ok,given that data-structure (which represents rent-slots in months of the items) where "x" stands f...
In Ruby, I need to time out the execution of a block of code after n milli seconds. I know that the Ruby Timeout library supports timeouts in seconds:
http://ruby-doc.org/stdlib/libdoc/timeout/rdoc/index.html
Is this possible?
...
As far as I know both rails:freeze:gems and rake gems:unpack are placing the gems to /vendor. rails:freeze:gems places them to /vendor/rails, gems:unpack place them to /vendor/gems. The point for me seems to be the same, however. In both cases the goal is to fix the gems and their versions as they were during the development. Is there an...
I have a data model involving Users and Awards, and joined by a user_awards table.
class User < ActiveRecord::Base
:has_many :user_awards
:has_many :awards, :through => :user_awards # awards the user has won
end
class Award < ActiveRecord::Base
:has_many :user_awards
:has_many :users, :through => :user_awards
end
I'd like th...
the html looks like below or you can find it here http://www.vbulletin.org/forum/index.php
<!-- login form -->
<form action="login.php?do=login" method="post" onsubmit="md5hash(vb_login_password, vb_login_md5password, vb_login_md5password_utf, 0)">
<script type="text/javascript" src="clientscript/vbulletin_md5.js?v=3612">...
How come ().nil? is true in Ruby?
...
i need to ignore anything that is one space, and empty space at least bigger than one space should be matched...
"MARY HAD A LITTLE LAMB"
i expect
"MARY", "HAD A LITTLE", "LAMB"
...
Hi, I wrote a small program that uses Mechanize to traverse a site.
I want to write tests for it, but don't want it to actually go log onto the site every time I run the tests. I would like to mock the internet, so that when it goes to some site, it simply returns the stored results.
Here is a small example, pretend my code's purpose ...
Can I replace an executable (accessed via a system call from ruby) with an executable that expects certain input and supplies the expected output in a consistent amount of time? I'm mainly operating on Mac OSX 10.6 (Snow Leopard), but I also have access to Linux and Windows. I'm using MRI ruby 1.8.7.
Background: I'm looking at doing sev...
I want to make my variable (a proxy object) evaluate to false when used in conditional sentences. I know I can use .nil? and even var == nil but I think that's not good enough. What I am trying go do is to:
if myproxy # not only myprroxy.nil? or myproxy == nil, but just that
# myproxy's backend object is not nil
else
# myproxy's bac...
This is probably easy but I'm a bit of a newbie on wrapping my head around these things sometimes.
Synopsis: I'm trying to make a checklist application that technicians go through and answer questions about what has been completed or done in the field. The technicians then submit this for review. The questions are created, managed, and ...