Getting webpage content with Ruby -- I'm having troubles
You really want to use open() provided by the Kernel class which can read from URIs you just need to require the OpenURI library first:
require 'open-uri'
Used like so:
require 'open-uri'
file = open('http://hiscore.runescape.com/index_lite.ws?player=zezima')
contents = file.read
puts contents
This related SO thread covers the same question:
Open an IO stream from a local file or url
Having troubles with all method and getting ArgumentError at
The "all" method doesn't take options. If you're looking to return an array of records with a number of conditions you want to use WHERE. The correct command would be:
posts = Post.includes(:account).where(:conditions => condition,
:order => "created_at DESC", :limit => postsPerPage,
:offset => (page-1)*postsPerPage)
For clarity:
.all
returns every record.where()
returns every record where the
conditions are met.find_by()
returns the first record where the
conditions are met.find()
returns the first record where the
primary key = the passed value
Whenever you see a wrong number of arguments 1 for 0 error, it means you're trying to pass values to a method which does not accept parameters.
As for why this problem only just surfaced, it appears there was some precedence for allowing .all to accept parameters in previous versions of ActiceRecord, but I am not familiar with this functionality, and cannot speak to it in detail. Daiku's comment on this answer effectively explains how this has changed.
Incomplete page load in Ruby On Rails
As per the comments, and Lurker's suggestion of searching for development specific configurations.
group :development do
in the gemfile and differences between config/environments/development.rb
and config/environments/production.rb
are a good start to help isolate problems specific to the development environment.
Ruby on Rails 4: Trouble with adding Javascript files in Rails web application
Since it's not a library but a set of custom js you should put it back into the app/assets/theme.js you had it in and not your vendor js folder. You then don't have to require it specifically since in your application.js file you have the "require tree" statement which will automatically include all files in your assets/js folder.
Also, it's usually a good idea to wrap all of that inside of a
$( document ).ready(function() {
all your js here...
});
It may be that your js is loading before the page now that you moved it into the asset pipeline at which point the DOM isn't compiled yet by the browser leaving all of your js broken.
Related Topics
Rails I18N via Database Column
-%>' (Minus Sign) at the End of a Erb Sequence
Fail VS. Raise in Ruby:Should We Really Believe the Style Guide
Rails - Get the Time Difference in Hours, Minutes and Seconds
Rails Strip Non Numeric Values Before Save
Calculating Difference in Time Between Two Time Objects
Converting Utf8 to Ansi with Ruby
How to Deal with Not Knowing What Exceptions Can Be Raised by a Library Method in Ruby
How to Set/Get Session Vars in a Rack App
How to Validate a Non-Model Form in Rails 3
Private Class (Not Class Method) in a Ruby Module
How to Append a String to a Variable That Either Exists or Not
How to Resolve Ruby Error (Missing Psych)
Rbenv: Surviving Without Gemsets
Is There an Equivalent to 'Array::Sample' for Hashes
Find Classes Available in a Module
How to Get Attributes That Were Defined Through Attr_Reader or Attr_Accessor