As you have probably already guessed, I’m using devise to handle my authentication. Unfortunately this seems to be overriding some of my routes whenever it co-exists with another form. Luckily there exists a very simple, although hard to find solution – simply add a forward slash before the controller definition:
Due to a few recent issues with SunSpot (see my previous posts), I’ve decided to uninstall it until I have enough time to work on it properly. Once again, Ruby makes this pretty simple:
chris@chris-VirtualBox:~/site$ sudo gem uninstall sunspot
[sudo] password for chris:
You have requested to uninstall the gem: sunspot-1.2.1 sunspot_rails-1.2.1 depends on [sunspot (= 1.2.1)]
If you remove this gems, one or more dependencies will not be met.
Continue with Uninstall? [Yn] y
Remove executables: sunspot-solr, sunspot-installer in addition to the gem? [Yn] y
Successfully uninstalled sunspot-1.2.1
I ran into a bit of a problem with a has_many relationship in rails today:
ActiveRecord::HasManyThroughAssociationNotFoundError in FeedbacksController#index
Could not find the association :sub_orders in model User
This turned out to be a fairly simple fix, I had forgotten to add a has_many relationship before adding the has_many :through => x relationship. There is a fairly detailed explanation on StackOverflow for anyone who is curious.
Unfortunately this problem also prevented me from performing any other migrations on the table. I attempted deleting all relevant migration files and then re-running them, restarting the server and rolling back to a previous migration – none of which worked.
Eventually I resorted to exporting the dataset, dropping the table via sqlite3 and recreating it. Thankfully this seems to have worked. The only hint I’ve come across that may explain the cause of this problem, other than typos or referring to non-existant columns, is that it can occur if a migration is screwed over before it finishes and fails to rollback properly.
If anyone else has any concrete answers, please let me know in the comments!
Just another quick problem I ran into with rails this afternoon – how to submit a form_for to a custom action. Luckily there’s quite a bit on how to do this in the documentation, my solution ended up as follows: