Tag: activerecord

No Method Error but i defined it

I got a NoMethodError when i called <%= @post.admin_user.name %>, don’t know how to fix it. Extracted source (around line #4): <h1><%= @post.title %></h1> <p><%= @post.body %></p> <small>Post created at <%= @post.created_at.strftime(‘%b %d. %Y’) %></small><br/> <br/> <%= @post.admin_user.name %> <p>Category: <%= link_to @post.category.name, category_path(@post.category.id) %></p> <%= link_to ‘Edit Post’, edit_post_path %> | <%= link_to ‘Go […]

Using AR in external script works unless called by system() from Rails

I’m calling an external script from rails with system() and I get this: /home/user/.rvm/gems/ruby-1.9.2-p180/gems/activerecord- 3.0.7/lib/active_record/connection_adapters/mysql_adapter.rb:22:in `rescue in mysql_connection’: !!! Missing the mysql2 gem. Add it to your Gemfile: gem ‘mysql2’ (RuntimeError) … This error is being caused by the external script, which loads rubygems and active record without rails. The script still works from the […]

Geokit query not returning expected data fields in Rails 3

I find myself a little stumped here. Included below are few examples of Rails code, corresponding SQL queries generated and the Rails output – I am using the geokit-rails3 gem. In each case, when I run the generated query in a SQL query window, I get the fields as one would expect from the SQL. […]

uninitialized constant ActiveRecord (NameError) – Cucumber and Cheese example

I am new to ruby and following along Cheezy’s example in his book Cucumber and Cheese. My gemfile looks like this: source ‘https://rubygems.org’ gem ‘cucumber’ gem ‘rspec’ gem ‘page-object’ gem ‘pry-debugger’ gem ‘faker’ gem ‘data_magic’ gem ‘debugger’, ‘1.6.6’ gem ‘require_all’ gem ‘activerecord’, ‘3.2.1’ gem ‘factory_girl’ gem ‘database_cleaner’ gem ‘sqlite3’ I have a file named database.rb […]

Delay job gem will not works in case the referred object changes its attribute

I am facing a very interesting problem. I have tested the Delay job gem 4 times. I doubt it is the design problem of the gem or a bug. I use command rake jobs:work to create worker to do delayed job. Once I create a LongTask record, i also make a delayed job which will […]

Rails how to add belongs_to to gem file

This is difficult for me to explain, but I need to add the belongs_to attribute to a model of a gem. I am using the APN_on_rails gem to add push notification functionality to my web app. In this gem it creates a model called Device (APN::Device) which has a few fields needed for it to […]

undefined method table_alias

When starting my rails application I get the following error. Can someone give me a hint where to search for an error? undefined method `table_alias’ for #<ActiveRecord::Relation:0x0000000339df20> This is my gemfile.lock GEM remote: http://rubygems.org/ specs: abstract (1.0.0) actionmailer (3.0.12) actionpack (= 3.0.12) mail (~> 2.2.19) actionpack (3.0.12) activemodel (= 3.0.12) activesupport (= 3.0.12) builder (~> […]

Error using activerecord-sqlserver-adapter

I installed activerecord-sqlserver-adapter such that it appears in my local gems. Running the command… rails generate scaffold Tablename fieldname:fieldtype returns an error (as below). I’ve rails 1.9.2 installed. Any guidance or assistance would be much appreciated. Thanks C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-.2.8/lib/active_support/dependencies.rb:251:in `require’: Please install the sqlserver adapter: `gem install activerecord-sqlserver-adapter` (no such file to load — active_record/connection_adapters/sqlserver_adapter) (LoadError) […]

Query tables imported via Rails gem

I have this gem (active_nutrition) that has basically imported a bunch of tables into my database. The gem comes with methods and such for getting the information from the imported tables easily. However, I now want to query for some info from those tables, but because it’s a gem, I can’t seem to query. For […]

How can I line up images using ActiveRecord

I am using Rails to achieve the following effect for a beauty item sales site Assuming I have the information stored on the DB how can I generate or display the items as shown in the picture while giving the user the option to click “Next” and continue viewing the other items. Is there a […]

Ruby is the best programming language in the world - Ruby on Rails.