Friday, May 23, 2008
Sunday, May 11, 2008
Rails.vim breaks in Hardy Heron
Well, Vim breaks when using rails.vim in Ubuntu 8.04 Hardy Heron. Took me a few days to decide to actually try and fix it and not downgrade back down to Gutsy.
This post explains what you can do to fix this error. We'll upgrade to the latest Vim. Because the error is caused by an old version of Vim and rails.vim, you need to update it. You can read about it in this thread. That was my starting point to find the fix.
1) Download and install the latest version of Vim
2) Install all the plugins and scripts again
3) If you use haml, when I downloaded the latest version today of the haml syntax script, I had some illegal carriage return errors. I had to open haml.vim then save it via
This post explains what you can do to fix this error. We'll upgrade to the latest Vim. Because the error is caused by an old version of Vim and rails.vim, you need to update it. You can read about it in this thread. That was my starting point to find the fix.
1) Download and install the latest version of Vim
svn co https://vim.svn.sourceforge.net/svnroot/vim/vim7
cd vim7
./configure --with-features=huge
sudo make
sudo make install
2) Install all the plugins and scripts again
3) If you use haml, when I downloaded the latest version today of the haml syntax script, I had some illegal carriage return errors. I had to open haml.vim then save it via
:w ++ff=unix
Saturday, March 22, 2008
GawingAttachable
Do you want to be able to attach files to something? I needed to do that today and I made a plugin called Gawing Attachable (translated: make_attachable). It allows you to add attachments to something you make attachable.
Yes, there are many things you can still do to this, but like they say: make something quick and fix it up later on.
Check out the README before installing.
Yes, there are many things you can still do to this, but like they say: make something quick and fix it up later on.
Check out the README before installing.
script/plugin install http://lucidph.dreamhosters.com/gawing_attachable/trunk
Generating a resource in the routes.rb file
When making a generator, you may want to add something to the routes.rb file. To understand this you need to know how to make generators. Take a look at Ryan Bates' Railscast on how to do this.
To add a normal resource, do it this way:
If you want to add other stuff like :member or :collection, do it this way
To add a normal resource, do it this way:
class GawingFileableGenerator < Rails::Generator::Base
def manifest
record do |m|
...
m.route_resources :files
end
end
end
If you want to add other stuff like :member or :collection, do it this way
class GawingFileableGenerator < Rails::Generator::Base
def manifest
record do |m|
...
route_string = ":files, :member => { :download => :get }"
def route_string.to_sym; to_s; end
def route_string.inspect; to_s; end
m.route_resources route_string
end
end
end
Wednesday, March 12, 2008
acts_as_state_machine: make initial state exists!
Ugh.. I tried out acts_as_state_machine and I kept getting this nil error and I had no idea why. I mean, I followed the code in agilewebdevelopment.com properly. Here's the code in that website:
Oh... apparently, you need to add
to it as well :)
acts_as_state_machine :initial => :created, :column => 'status'
# These are all of the states for the existing system.
state :submitted
state :processing
state :nonprofit_reviewing
state :accepted
Oh... apparently, you need to add
state :created
to it as well :)
Monday, March 3, 2008
Expected User, got User; forcing to reload plugins
I made my own plugin and started getting this error. This plugin is a variation of the acts_as_voteable plugin by Juixe. I did some searching around, I found this blog post that explains the fix.
Apparently, in development mode, there are issues when it comes to reloading plugins. Because the model "Vote" in my case, or "Comment" in the blog post's case, is defined inside the plugin, Rails doesn't see that it should load it again. Anyway, better to read that post for an explanation.
What I did to fix it was add this code at the end of the environment.rb file:
Apparently, in development mode, there are issues when it comes to reloading plugins. Because the model "Vote" in my case, or "Comment" in the blog post's case, is defined inside the plugin, Rails doesn't see that it should load it again. Anyway, better to read that post for an explanation.
What I did to fix it was add this code at the end of the environment.rb file:
# Array of plugins with Application model dependencies.See the code.
reloadable_plugins = ["acts_as_commentable"]
# Force these plugins to reload, avoiding stale object references.
reloadable_plugins.each do |plugin_name|
reloadable_path = RAILS_ROOT + "/vendor/plugins/#{plugin_name}/lib"
Dependencies.load_once_paths.delete(reloadable_path)
end
Labels:
error,
expected User,
force reload,
got User,
plugins
Wednesday, February 27, 2008
Creating your own plugin
I finally forced myself to make my own plugin instead of having controllers and models all over the place. Of course, I waited for the right time to make a plugin that wasn't too different, and needed to be different at the same time.
I chose to make another version of acts_as_voteable by Juixe. Here are the steps I took
The change I had to make to acts_as_voteable was that I had to have 3 kinds of votes: positive, neutral and negative. Very small change, right? :)
You can get my plugin like this:
script/plugin install http://lucidph.dreamhosters.com/gawing_voteable/trunk
I chose to make another version of acts_as_voteable by Juixe. Here are the steps I took
- I watched Ryan Bates' screencast on making plugins
- I coped acts_as_voteable and starting editing things one by one to see what broke.
- When I needed a clearer and more advanced explanation (like adding helpers and such), I referred to Geoffrey G's howto on creating plugins.
The change I had to make to acts_as_voteable was that I had to have 3 kinds of votes: positive, neutral and negative. Very small change, right? :)
You can get my plugin like this:
script/plugin install http://lucidph.dreamhosters.com/gawing_voteable/trunk
Subscribe to:
Posts (Atom)