In my permissions controller, I use Active record to look for a permission:
@permission = Permission.find(params[:user_id])
If this returns a result I then look up the permission.name And pass this to my controller.
Problem is sometimes this does returna result, othertimes it does not. When it does not, it errors. How can I prevent t...
I'm trying to seed a database in Rails 3 with images using CarrierWave, however nothing I try seems to work short of having to upload them all by hand.
pi = ProductImage.new(:product => product)
pi.image = File.open(File.join(Rails.root, 'test.jpg'))
pi.store_image! # tried with and without this
product.product_images << pi
product.save...
I have an idea for a simple web application and I've heard a lot about Ruby, Ruby on Rails, Python, PHP, etc.
But what language do you think is better to have working prototypes and get the application running online really quick?
NOTE: This is not a question about the language's performance, I am just trying to find the best language...
I have a polymorphic association relationship happening, and when I retrieve a record through it, such as:
hour = my_model.find( keeper_id ).hours.where( "day = ?", day_index )
Then try to call update_attributes on it:
hour.update_attribute(:start_time, start_time)
I get an error:
NoMethodError (undefined method `update_attribute'...
I use the Sunspot gem in my RoR app to do searches on the Post model, and it works great for that. However, I need to use it's matching algorithm against a single post object.
For example, I can search all Posts like this:
Sunspot.search Post do
...
end
But, I need to do the search against a single post object, like so:
Sunspot.se...
I am using Ruby 1.8.7 with Rails 2.3.9. When creating a drop down of email addresses using collection select, the emails addresses are not displaying. Instead I am seeing "[email protected]" in the drop down. Is there some switch that is causing this?
There seems to be some javascript that is being applied to each item in the drop d...
Hello, could really use your help, understanding this complex rails issue I've been banging by head against the wall on...
I have the following Models:
Permissions (user_id, role_id, project_id)
Roles (id, name)
Projects (id, name)
Permissions is the Y model for Roles and Projects.
I'm struggling to make a form to allow a user t...
Maybe it can be put into a helper but the existing 500 lines of code has everything in the HAML code, so it is better to follow the existing code for the moment (for tight deadlines).
I found the only way working right now is
- meta_tag = %Q{\n |
<meta ...>\n |
<meta ...>\n |
[...] \n |
} |
which is to use the "continuati...
I am looking for a piece of software that will allow me to use Ruby on Rails 2.3.8 on top of MACOSX - basically, I teach at a college where students are not able to get terminal acccess to the rails built into OSX so I am looking for a piece of software like "Locomotive" that is an app that allows students to use rails without administra...
I was trying to redirect to a different page after editing an entry, I assumed that it was using the update code because you are updating the database. It took me some time to realise that I was using the wrong action in the controller. Can someone please explain how edit and update work. Why are there two different actions? what are t...
I'm getting a Routing error when trying to access my page.
Routing Error
No route matches "/" with {:method=>:get}
The error log reads:
[4;36;1mSQL (0.1ms)[0m [0;1mSET NAMES 'utf8'[0m
[4;35;1mSQL (0.0ms)[0m [0mSET SQL_AUTO_IS_NULL=0[0m
Processing ApplicationController#index (for 68.116.193.166 at 2010-10-11 19:18:16) [GET]
...
So I have 2 models, listings, and houses. Houses can be made independently, while all listings must be associated with a house (this a an apartment-finding site). I am trying to build a form for a new listing which has a column alongside of houses already in the database. If the user sees their house, they click it, and the form auto-fil...
I'm writing a quick app for a user to track their daily bills (for money tracking purposes). I want the user to be able to define their own categories that a bill can be applicable for. I'm trying however to decide the best way to model this and also validate categories as unique.
My initial thought was this:
class User
include Mon...
I'm currently reading through the beta version of The Rspec Book: http://www.pragprog.com/titles/achbd/the-rspec-book
It describes The Behaviour Driven Development Cycle (red, green, refactor) as taking small steps during the development process. This means adding features one at a time.
My question is:
If I were to describe a single...
I use php and there is a handy exit; that will stop the execution of the page and let me view the page thus far and then lets me view the debugging that i need ..anything like that in ruby on rails
...
Hi folks,
Just meddling with Rails at the moment, and struggling to figure out how to escape "you have a nil object when you didn't expect it" errors . At the moment I'm escaping each of them with an "unless object.nil?" message, but it's getting pretty ugly. Case in point:
unless params[:professiontypeinfo].nil?
unless params[:profe...
I'm using Restclient (HTTP and REST client for Ruby) to check if a URL is valid. The Restclient response wraps Ruby's Net::HTTPResponse.
p (RestClient.get "www.google.com").code == 200 # outputs true
The problem is, if the URL isn't valid, the app crashes:
p (RestClient.get "test").code == 200
SocketError (getaddrinfo: nodename no...
I have a model for a task which has a name, description, the process it belongs to, the position and a category.
As there are only two different categories I have created additional controllers specific to the categories as they need to be treated differently. when i submit the edit form in one of the category controllers it is redirect...
I currently have a generic list that is generated by ActiveScaffold. At the end of each row in the list, ActiveScaffold adds the standard CRUD links - Show, Edit, Delete - for each record.
I do not wish to use ActiveScaffold for these actions (long story) and have created my own controllers to handle this. I am trying to override these ...
Feature: list video in stored
Background:
Given I have the following videos
| title | format |
| Running Central Park in the Fall | BluRay |
| Running Glacier Park in the Spring | Download |
| Running Balboa Park in the Winter | DVD |
...