I have a Book < LibraryItem and a Book::Page, which is defined as class Book class Page in models/book/page.rb LibraryItem has a method called can_edit? But my Book::Page.new.can_edit? returns no method error... how do I include the instance methods from LibraryItem in my namespace? ...
Given a comma seperated csv file in the following format: Day,User,Requests,Page Views,Browse Time,Total Bytes,Bytes Received,Bytes Sent "Jul 25, 2012","abc123",3,0,0,13855,3287,10568 "Jul 25, 2012","abc230",1,0,0,1192,331,861 "Jul 25, 2012",,7,0,0,10990,2288,8702 "Jul 24, 2012","123456",3,0,0,3530,770,2760 "Jul 24, 2012","abc123",19,1,30,85879,67791,18088 I wanted to drop the entire dataset (1000 users over 30 days = 30,000 records) into a hash such that Key 1 may be a duplicate ...
I am querying data from Salesforce using Ruby. Now, I can query standard fines. Example of my query: data=driver.query(:queryString => "select ID, Website,Test_Custom__c from Account where id='001A000000L4d3Y' LIMIT 1").result.records If I put: puts data[0].website The value for that field displays fine. But, if I put: puts data[0].test_custom__c I get the following error: undefined method `test_custom__c' ...
I get a ActiveModel::MassAssignmentSecurity::Error when I try to running my app to save the login and password details. got the following error Can't mass-assign protected attributes: name, password, password_confirmation, salt app/controllers/users_controller.rb:43:in new' app/controllers/users_controller.rb:43:increate' here is the code from the control file class UsersController < ApplicationController # GET /users # GET /users.json ...
This is related with unicode support. The current RPG Maker ruby version is 1.8, The problem is, using english RPG Maker, one cannot display non-standard character such as kanji (japanese characters) inside game's message window. The text was stored properly in a variable but messed up when being shown on ...
I'm trying to deploy a Rails app using Passenger. I followed this guide: http://wiki.ocssolutions.com/Deploying_a_Rails_Application_With_Passenger and got all my gems installed, but when I go to the location where my app should be, I see The page you were looking for doesn't exist. You may have mistyped the address or ...
I receive very interesting and seemingly erratic results in irb for Ruby. What is going on? This is correct! >> 23+9.22 => 32.22 This is not! >> 23+9.23 => 32.230000000000004 Where are all the trailing zeroes coming from? What is going on? ...
I have a model car When I update the car object through a form in my application, paper trail plugin is called and a new version is created. But if I test this thing using rspec, paper trail plugin is never called. Any idea why is paper_trail not being called ...
We're using the Ruby-RTF gem, found on Github. Essentially, we want to generate a report document that contains the image of a chart, a simple table, and a couple of paragraphs, in a format that the user can use (copy/paste, etc); meaning a PDF wouldn't be an option ...
ruby 1.9.2p290 rails 3.1.1 I have the following routes output: http://localhost:3001/chefs/peter (shows the chef profile **based on username**) http://localhost:3001/chefs/edit (can edit their profile if logged) How to prevent user to create a username that already has a action name like edit? ...
A very simple question, but I'm new to Ruby and not able to determine the name of this type of data structure: location = 145.6, 56.644 I searched for point, pair, comma-seperated value etc. but was not successful. Could you tell me what this is? Thank you ...
I am trying to create a login/password web app. Getting the following error while running the app. undefined method encrypt_pasword' app/models/user.rb:32:inpassword=' app/controllers/users_controller.rb:43:in new' app/controllers/users_controller.rb:43:increate' Here is the code from control file. require 'digest/sha2' class User < ActiveRecord::Base include ActiveModel::MassAssignmentSecurity attr_accessible :name, :password, :password_confirmation, :hashed_password, :salt attr_accessor :name attr_accessor :salt validates :name, ...
Lately I get a very strange error at the following line of code: IO.binwrite(attachmentUploadFile, attachmentFileContent) This is the full error message: import.rb:326:in `block (3 levels) in <main>': undefined method `binwrite' for IO:Class (NoMethodError) from /Users/juuro/.rvm/gems/ruby-1.9.2-p290/gems/zippy-0.2.1/lib/zippy.rb:144:in `open' from import.rb:321:in `block (2 levels) in <main>' from import.rb:320:in `each' from import.rb:320:in `block in <main>' from import.rb:167:in `each' from import.rb:167:in `<main>' It worked perfectly ...
Ok so i have a Contact model class Contact < ActiveRecord::Base has_one :profile validates_presence_of :first_name validates_presence_of :last_name validates_presence_of :email class Profile < ActiveRecord::Base belongs_to :contact And on my form i have fields from that profile and the contact and the validations for the contacts show up ...
I'm confused about how to avoid Law of Demeter violations with one-to-many associations. Let's say I have a model like this: class Organization < ActiveRecord::Base has_one :address has_many :employees end I believe that it would be a Law of Demeter violation to do this: organization.address.street_name This could be avoided by having a *address_street_name* ...
After creating a file and populating data into it, before close, need read part data and calculate the checksum. The issue is you cant read the data before close the file. Code snippet is as follows. My question is how to create a file, write data, read part of ...
What's the simplest way in Ruby to group an array of arrays by element order? In other words, to get all the 0th elements, then all the 1th elements, etc. So if you started with this: [[1,2], [:a, :b], [:alpha, :beta]] you'd get this: [[1, :a, :b], [2, :b, :beta]] I can do it with ...
Using devise, rails 3.2. I'm trying to figure out how to create an array of ids and then check if the current_user's id is included in this array. My users have many locations through location_users. (Locations have many users through the same relationship.) I can get a list of user_ids associated with ...