A few years ago I heard of this small app called Alfred. I started playing with it while it was still in its first Beta. After a few days of using it I know it was an app that would make a huge change in my workflow. I also knew I wanted to support the developers as much as I could so I bought the app as a “Mega Supporter”. Now I never thought that I would get anything extra for this, but it turns out that the developers wanted to thank their supporters by giving them early access to Alfred 2. (more…)
Learn MoreI’ve recently went back to an old project and it seems to have stopped working giving me this error:
|
1 |
~/projectx/vendor/ruby/1.9.1/gems/devise-2.0.0/lib/devise/rails/routes.rb:391:in `raise_no_devise_method_error!': User does not respond to 'devise' method. This usually means you haven't loaded your ORM file or it's being loaded too late. To fix it, be sure to require 'devise/orm/YOUR_ORM' inside 'config/initializers/devise.rb' or before your application definition in 'config/application.rb' (RuntimeError) |
[read full stack trace at: gist]
Since I didn’t really change anything, I was surprised to see it break. So I tried to do what it said, I changed that I had a require statement for my ORM which was Mongoid. I had: (in config/devise.rb)
|
1 2 3 4 5 6 7 8 |
Devise.setup do |config| # ==> ORM configuration # Load and configure the ORM. Supports :active_record (default) and # :mongoid (bson_ext recommended) by default. Other ORMs may be # available as additional gems. require 'devise/orm/mongoid' # ... more settings ... end |
While working hard at getting an application up and running for a lunch tomorrow, I ran into this annoying screen:

So I re-read the message and followed the included link from the message and found this:

I recently updated one of my apps to Rails 3.1 and found that my PDF generating tests were failing because they were unable to find the CSS or images to use in the PDF.
So I started playing around, and here is what I got:
In your app, add a new initializer (or edit your existing wicked_pdf.rb initializer) and put the following:
As you can see in the code, I also replaced the background urls with correct references, this is assuming that you’re keeping your CSS images in the same location as your normal images (which I don’t see a reason why not but of course you can always tweak the script)
I had one issue with my generated PDF using pow.cx, my CPU would jump to 100% (on the pow process) and the page would timeout. After upgrading to the latest version of pow (0.3.2) using this command:
|
1 |
curl get.pow.cx | sh |
I was able to see my PDFs without an issue.
http://blog.phusion.nl/2011/08/14/rendering-rails-3-1-assets-to-string/
https://github.com/mileszs/wicked_pdf/issues/48
Small change to the above code to fix issue that prevented CSS from being rendered correctly.
Learn MoreEver wonder how you can write a cucumber test that would test how your web app responds to a different format, something like JSON or XML?
I was trying to do the following:
|
1 2 3 4 5 6 7 8 9 10 11 12 |
Background: Given I am logged in And there is the following feeds: | title | body | category | | first feed | something good | default | | second feed | even better | notice | | 3rd feed | something awesome | notice | Scenario: Reading feeds via json When I go to the feeds page using json And I should see a json file And I should see 3 feeds in the json |
Running this code I would get a “Can’t find mapping from “the feeds page using json” to a path.”
Trying to figure out how I can do this, I tried to write a new step, like this:
|
1 |
When %r{^I go to the (w+) page using (w+)$} do |page, format|... |
but this resulted in: Ambiguous match of “I go to the feeds page using json”
So, I posted the question on StackOverFlow and it seems everyone was thinking the same way I was.
I continued playing with this idea and here is how I solved the problem:
Modifying the paths.rb file, I changed (Changes are in bold)
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
def path_to(page_name) # Split out format if page_name includes ' using ' # Example: When I go to the accounts page using json <strong>page_name, format = page_name.split(' using ')</strong> case page_name when /the homes?page/ '/' when /the new account page/ #pass format new_account_path(<strong>:format => format</strong>) else begin page_name =~ /the (.*) page/ path_components = $1.split(/s+/) # Also make sure to pass format to the 'guessed' path self.send(path_components.push('path').join('_').to_sym<strong>, :format => format</strong>) rescue Object => e raise "Can't find mapping from "#{page_name}" to a path.n" + "Now, go and add a mapping in #{__FILE__}" end end end |
This way I don’t have to modify anything else in my features and everything just works.
Learn MoreToday I’m thinking of getting back into so good old work and I read there is a new patch to Ruby, version p330. So I figure that RVM (Ruby Version Manager) being so easy and quick to update, I’d do the good old “rvm get head, rvm reload, rvm update 1.8.7″ and I’m off to the races.
Well it wasn’t quite as simple. I ended up with an error:
ruby-1.8.7-p330 - #fetching
ruby-1.8.7-p330 - #extracting ruby-1.8.7-p330 to /Users/andrew/.rvm/src/ruby-1.8.7-p330
ruby-1.8.7-p330 - #extracted to /Users/andrew/.rvm/src/ruby-1.8.7-p330
ruby-1.8.7-p330 - #configuring
ruby-1.8.7-p330 - #compiling
Error running 'make ', please read /Users/andrew/.rvm/log/ruby-1.8.7-p330/make.log
There has been an error while running make. Halting the installation.
When I looked into the the make.log, It had this to say:
readline.c: In function ‘username_completion_proc_call’:
readline.c:730: error: ‘username_completion_function’ undeclared (first use in this function)
readline.c:730: error: (Each undeclared identifier is reported only once
readline.c:730: error: for each function it appears in.)
So, I figured this was going to take too long to deal with, and moved on to working on my projects. That is till I opened up my project and and did a “rvm 1.8.7@rails3″ and it come up with:
warn: ruby ruby-1.8.7-p330 is not installed.
To install do: 'rvm install ruby-1.8.7-p330'
Great! Now I can’t upgrade, and I can’t work with what I have!
Long story short, I figured out that I was missing readline (now I’m sure I’ve installed in a long while ago, but I think I was missing the latest version). Also, rvm install readline resulted in an “Unrecognized command line argument: ‘readline’ ( see: ‘rvm usage’ )”
Turns out RVM updated it’s command to install readline to:
rvm package install readline
Update: (Nov 10, 2011)
If you’re using a newer version of RVM, package has been renamed to pkg, so the command to install readline would be:
rvm pkg install readline
However this didn’t fix my install issue, still got the same error. Luckily I found a post that pointed out that my rvm may not know where readline is (odd, as I used rvm to install readline). Running this command allowed me to install it correctly:
rvm install 1.8.7 -C –with-readline-dir=/Users/andrew/.rvm/usr
[Notice: 'andrew' is my username on my mac, yours might be different]
rvm install 1.8.7 -C --with-readline-dir=$rvm_path/usr
Like always, I’m hoping this helps some people out.
Let me know if you have any issues.
Learn MoreTrying to run:
sudo apachectl restart
Are you getting:
/usr/sbin/apachectl: line 82: ulimit: open files: cannot modify limit: Invalid argument
Edit your /usr/sbin/apachectl on line 65 from:
ULIMIT_MAX_FILES="ulimit -S -n ulimit -H -n"
to:
ULIMIT_MAX_FILES=""
and try again. It should now be working agian
For more information checkout Deversus
Learn More