Help please

Getting this error:

SyntaxError in CompanyController#positionslist
(eval):1:in `compute_type’: compile error
(eval):1: parse error, unexpected tINTEGER
Object::2

I could not find anything out about it (googling) and it’s not the
clearest error message. Not sure if it’s related to an expected data
type but that wouldn’t make sense. The only other thing I can think
of is the view only has place holders for 6 of the 12 columns. Think
it’s 12 :).

<%= (position.title) %> <%= (position.category.name) %> <%= (position.comapny_id) %> <%= (position.city) %> <%= (position.state.name) %> <%= (position.entered_on_date) %>

Here is the method in the controller:
def positionslist
@positions = (Position.find_all)
end

The model:
class Position < ActiveRecord::Base
belongs_to :category
belongs_to :contactmethod
belongs_to :edureq
belongs_to :expreq
belongs_to :postlength
belongs_to :securityclear
belongs_to :state

  def self.find_all
find(:all)

end

end

Maybe something jumps out at someone ?

TIA
Stuart

I believe that views want strings passed to them in the <%= %>

option 1. <%= some.value.to_s -%>
option 2. <%= “#{somel.value}” %>

Hopefully that will fix it.

Hey Stuart, with the error dump you supplied it’s hard to tell what’s
up, but your code looks a little suspicious:

  1. the view references position, not @positions (I gather is a
    partial :collection => @positions ?)
  2. but the Class method find_all is most “disturbing”.
    Position.find_all is already defined by AR - even if you’re
    overriding, it’s defined incorrectly (I think),

should be:

def self.find_all
Position.find(:all)
end

I’d just kill it entirely, unless you’re intending on juicing it up
with more code.

Those are just a couple of thoughts Stuart that I hope help. If you
can provide a stack trace from the development.log we’ll have a
better chance helping out.

Jodi

You’ve got a typo somewhere else in your controller. Try posting the
code for the entire controller and I’ll see if I can spot the problem.

On 6/21/06, Jodi S. [email protected] wrote:

Hey Stuart, with the error dump you supplied it’s hard to tell what’s
up, but your code looks a little suspicious:

  1. the view references position, not @positions (I gather is a
    partial :collection => @positions ?)

I’m still investigating this but it wasn’t intended or set up as a
partial.

I’d just kill it entirely, unless you’re intending on juicing it up
with more code.

Those are just a couple of thoughts Stuart that I hope help. If you
can provide a stack trace from the development.log we’ll have a
better chance helping out.

Jodi

Here is the stack trace:

SyntaxError ((eval):1:in compute_type': compile error (eval):1: parse error, unexpected tINTEGER Object::2 ^): C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:1244:incompute_type’
C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:983:in
instantiate_without_callbacks' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/callbacks.rb:215:ininstantiate’
C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:390:in
find_by_sql' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:390:infind_by_sql’
C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:924:in
find_every' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:381:infind’
C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/deprecated_finders.rb:37:in
find_all' /app/controllers/company_controller.rb:5:inpositionslist’
C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/base.rb:910:in
perform_action_without_filters' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/filters.rb:368:inperform_action_without_benchmark’
C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/benchmarking.rb:69:in
perform_action_without_rescue' C:/INSTAN~1/ruby/lib/ruby/1.8/benchmark.rb:293:inmeasure’
C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/benchmarking.rb:69:in
perform_action_without_rescue' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/rescue.rb:82:inperform_action’
C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/base.rb:381:in
process_without_filters' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/filters.rb:377:inprocess_without_session_management_support’
C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/session_management.rb:117:in
process' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/dispatcher.rb:38:indispatch’
C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/webrick_server.rb:115:in
handle_dispatch' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/webrick_server.rb:81:inservice’
C:/INSTAN~1/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in service' C:/INSTAN~1/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:inrun’
C:/INSTAN~1/ruby/lib/ruby/1.8/webrick/server.rb:173:in
start_thread' C:/INSTAN~1/ruby/lib/ruby/1.8/webrick/server.rb:162:instart_thread’
C:/INSTAN~1/ruby/lib/ruby/1.8/webrick/server.rb:95:in start' C:/INSTAN~1/ruby/lib/ruby/1.8/webrick/server.rb:92:instart’
C:/INSTAN~1/ruby/lib/ruby/1.8/webrick/server.rb:23:in start' C:/INSTAN~1/ruby/lib/ruby/1.8/webrick/server.rb:82:instart’
C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/webrick_server.rb:67:in
dispatch' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/commands/servers/webrick.rb:59 C:/INSTAN~1/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:inrequire’
C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in
require' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/commands/server.rb:30 C:/INSTAN~1/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:inrequire’
C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in
`require’
script/server:3

Sorri for my short post before… I’m at work and, well you know…

On 6/22/06, Dark A. [email protected] wrote:

type but that wouldn’t make sense. The only other thing I can think
of is the view only has place holders for 6 of the 12 columns. Think
it’s 12 :).

<%= (position.title) %> <%= (position.category.name) %> <%= (position.comapny_id) %> <%= (position.city) %> <%= (position.state.name) %> <%= (position.entered_on_date) %>

In here assuming that in the view you have something like
<% @positions.each do |position| %>

<%= position.title %> <%= position.category.name %> <%= "#{position.comapny_id}" %> <%= "#{position.city}" %> <%= position.state.name %> <%= "#{position.entered_on_date.to_date}" %> <% end %>

I have made modifications I believe may help you.

Here is the method in the controller:

  belongs_to  :postlength
  belongs_to  :securityclear
  belongs_to  :state

I would include some validation here.

validates_presence_of :entered_on_date
validates_presence_of :city
validates_associated :state
validates_associated :category

By including these things you won’t have to worry in your view if
something
is nil or not. Alternatively you could put unless (object to go between
<%=
%>).nil? eg

<%= position.state.name unless position.state.nil? %>
  def self.find_all

Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

I hope that this will assist with your problem.

Stuart, google says:

http://lists.rubyonrails.org/pipermail/rails/2006-April/033467.html

Do you by chance have a field named ‘type’ in one of your tables?
Seems it’s a reserved word and compute_type will choke on it.

Jodi

There isn’t much to the controller.

class CompanyController < ApplicationController
scaffold :position

def positionslist
@positions = (Position.find_all)
end

end

Stuart

On 6/22/06, Dark A. [email protected] wrote:

<td><%= (position.category.name) %></td>

I appreciate the confidence but sadly enough it’s not in there , and
that is an important part of getting rows returned. My apologies. I’m
not at the machine right now but this will be the first place to
start.

If that @postions.each do |position| is not in your view, or you don’t
have
a line that looks like ,
<%= render :partial => ‘position’, :collection => @positions %> Then
there
is not a usual way for looping through the list of positions in your
views.

Unless you have some kind of loop construct that sets up the local
positionor you have specifically set it up, it will not be set in your
view. Since
you’re not getting a nil error I don’t think this is an error. It must
be
looping somewhere.

<% end %>

I have made modifications I believe may help you.

Are you showing examples for the string interpolation or you think
those particular fields would require it ?

Yes, I’m showing the fields that I think will require interpolation.
If
it’s not a string, you need to make it one. (at least that’s my
understanding of erb)

On 6/21/06, Daniel N [email protected] wrote:

Sorri for my short post before… I’m at work and, well you know…

No apologies necessary, totally appreciate any help I get.

In here assuming that in the view you have something like
<% @positions.each do |position| %>

I appreciate the confidence but sadly enough it’s not in there , and
that is an important part of getting rows returned. My apologies. I’m
not at the machine right now but this will be the first place to
start.

<% end %>

I have made modifications I believe may help you.

Are you showing examples for the string interpolation or you think
those particular fields would require it ?

  belongs_to  :expreq

validates_associated :category

By including these things you won’t have to worry in your view if something
is nil or not. Alternatively you could put unless (object to go between <%=
%>).nil? eg

<%= position.state.name unless position.state.nil? %>

Will do, I was holding off until I created the funnctions for creating
and editing to the table. This is just a list.

   def self.find_all
find(:all)

end

end

Maybe something jumps out at someone ?

I’ll have to make sure I have Active Record::Base reference opened
when I get back to this.

Stuart

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs