# Rails2.2.2, is it a bug?

**URL:** <https://www.ruby-forum.com/t/rails2-2-2-is-it-a-bug/155752>\
**Category:** Rails\
**Created:** [December 16, 2008, 10:37am UTC](https://www.ruby-forum.com/t/rails2-2-2-is-it-a-bug/155752 "2008-12-16T10:37:14Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![SSSB9SfFSSB](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/2bfe46/32.png) [@SSSB9SfFSSB](https://www.ruby-forum.com/u/SSSB9SfFSSB)\
**Post date:** [December 16, 2008, 10:37am UTC](https://www.ruby-forum.com/t/rails2-2-2-is-it-a-bug/155752/1 "2008-12-16T10:37:14Z")

</div>

yesterday, i make a demo with Rails2.2.2.

* * *

## model : Movie

class Movie \< ActiveRecord::Base  
has\_many :releases, :dependent =\> :destroy  
validates\_presence\_of :title  
end

* * *

## model: Release

class Release \< ActiveRecord::Base  
belongs\_to :movie  
validates\_presence\_of :movie\_id, :format, :released\_on

def to\_s  
[self.format, released\_on.to\_s(:short)].join(’ - ')  
end  
end

* * *

## controller: release\_controller

class ReleasesController \< ApplicationController  
def show  
@release = Release.find(params[:id])

```
respond_to do |format|
  format.html # show.html.erb
  format.xml { render :xml => @release }
end

```

end  
end

* * *

## app/views/release/show.html.erb

**Movie:** \<%=h @release.movie\_id %\>

**Format:** \<%=h @release.format %\>

**Released on:** \<%=h @release.released\_on %\>

\<%= link\_to ‘Edit’, edit\_release\_path(@release) %\> |  
\<%= link\_to ‘Back’, releases\_path %\>

it’s correct, it works ! but , when i modify the show page as  
following:

**Movie:** \<%=h @release.movie.title %\>

**Format:** \<%=h @release.format %\>

**Released on:** \<%=h @release.released\_on %\>

\<%= link\_to ‘Edit’, edit\_release\_path(@release) %\> |  
\<%= link\_to ‘Back’, releases\_path %\>

there is have a error. “Attempt to call private method” —  
format

Could u help me ?

---

<div class="post-metadata">

**Author:** ![SSSB9SfFSSB](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/2bfe46/32.png) [@SSSB9SfFSSB](https://www.ruby-forum.com/u/SSSB9SfFSSB)\
**Post date:** [December 16, 2008, 1:53pm UTC](https://www.ruby-forum.com/t/rails2-2-2-is-it-a-bug/155752/2 "2008-12-16T13:53:01Z")

</div>

On Tue, Dec 16, 2008 at 1:36 AM, e$B9@fFe(B [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> there is have a error. “Attempt to call private method” —  
> format

See: [http://wiki.rubyonrails.org/rails/pages/ReservedWords](http://wiki.rubyonrails.org/rails/pages/ReservedWords) – the  
“reported to cause trouble” section includes ‘format’.

You might want to rename that attribute of your model.

## HTH,

Hassan S. ------------------------ removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![SSSB9SfFSSB](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/2bfe46/32.png) [@SSSB9SfFSSB](https://www.ruby-forum.com/u/SSSB9SfFSSB)\
**Post date:** [December 17, 2008, 10:35am UTC](https://www.ruby-forum.com/t/rails2-2-2-is-it-a-bug/155752/3 "2008-12-17T10:35:24Z")

</div>

Thank you.

I know the ‘format’ cause trouble, it’s a private method , cause  
stop calling method\_missing,  
I change ‘format’ to ‘formater’ or other form, it’s be fine.

## but why this is good :

## app/views/release/show.html.erb

**Movie:** \<%=h @release.movie\_id %\>

**Format:** \<%=h @release.format %\>

**Released on:** \<%=h @release.released\_on %\>

\<%= link\_to ‘Edit’, edit\_release\_path(@release) %\> |  
\<%= link\_to ‘Back’, releases\_path %\>

Could u help me understand it ?

On Dec 16, 8:52 pm, “Hassan S.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![SSSB9SfFSSB](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/2bfe46/32.png) [@SSSB9SfFSSB](https://www.ruby-forum.com/u/SSSB9SfFSSB)\
**Post date:** [December 17, 2008, 11:53am UTC](https://www.ruby-forum.com/t/rails2-2-2-is-it-a-bug/155752/4 "2008-12-17T11:53:33Z")

</div>

Did you mean: You got the error in the Model, but it was worked in the  
View?

Maybe you can try this in the Model:

self[:format] replace self.format

On Wed, Dec 17, 2008 at 5:34 PM, æµ©ç¿” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> * * *
> 
> > You might want to rename that attribute of your model.
> > 
> > ## HTH,
> > 
> > Hassan S. ------------------------ removed\_email\_address@domain.invalid

–  
TWRUG Blog:  
[http://blog.rubyonrails.org.tw](http://blog.rubyonrails.org.tw)

CFC on Rails:

> **[CFC on Rails](http://zusocfc.blogspot.com)**
>
> 火車請別撞我

Only two surfaces of a box:  
[http://blog.pixnet.net/zusocfc](http://blog.pixnet.net/zusocfc)

---

<div class="post-metadata">

**Author:** ![SSSB9SfFSSB](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/2bfe46/32.png) [@SSSB9SfFSSB](https://www.ruby-forum.com/u/SSSB9SfFSSB)\
**Post date:** [December 18, 2008, 4:22pm UTC](https://www.ruby-forum.com/t/rails2-2-2-is-it-a-bug/155752/5 "2008-12-18T16:22:52Z")

</div>

Same as the model  
Change @release.format to @release[:format]  
🙂  
Cause format is a private method, so you can’t call it.  
No matter it is in the model or in the view.  
So, you can use model[:method] to grab the correct column.  
Or, you can try to use: read\_attribute(“format”) in the model 🙂

On Thu, Dec 18, 2008 at 10:11 PM, æµ©ç¿” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> * * *
> 
> %=h @release.movie.title %\>, when i called show action , it
> 
> > Did you mean: You got the error in the Model, but it was worked in the
> > 
> > > Thank you.  
> > > **Movie:**  
> > > \<%=h @release.released\_on %\>
> > > 
> > > > > there is have a error. “Attempt to call private method” —
> > 
> > –  
> > TWRUG Blog:[http://blog.rubyonrails.org.tw](http://blog.rubyonrails.org.tw)
> > 
> > CFC on Rails:[http://zusocfc.blogspot.com](http://zusocfc.blogspot.com)
> > 
> > Only two surfaces of a box:[http://blog.pixnet.net/zusocfc](http://blog.pixnet.net/zusocfc)

–  
TWRUG Blog:  
[http://blog.rubyonrails.org.tw](http://blog.rubyonrails.org.tw)

CFC on Rails:

> **[CFC on Rails](http://zusocfc.blogspot.com)**
>
> 火車請別撞我

Only two surfaces of a box:  
[http://blog.pixnet.net/zusocfc](http://blog.pixnet.net/zusocfc)

---

<div class="post-metadata">

**Author:** ![SSSB9SfFSSB](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/2bfe46/32.png) [@SSSB9SfFSSB](https://www.ruby-forum.com/u/SSSB9SfFSSB)\
**Post date:** [December 18, 2008, 5:35pm UTC](https://www.ruby-forum.com/t/rails2-2-2-is-it-a-bug/155752/6 "2008-12-18T17:35:12Z")

</div>

Hi,Am Almas M totally new to this site i was jst going the site of  
Ruby’s on  
Rails i hav no idea how am i to begin with.It would be really gud if u  
guide  
and let me wht is it all about.

Rdgs  
Almas

---

<div class="post-metadata">

**Author:** ![SSSB9SfFSSB](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/2bfe46/32.png) [@SSSB9SfFSSB](https://www.ruby-forum.com/u/SSSB9SfFSSB)\
**Post date:** [December 18, 2008, 3:12pm UTC](https://www.ruby-forum.com/t/rails2-2-2-is-it-a-bug/155752/7 "2008-12-18T15:12:18Z")

</div>

Thank you.  
I know the issue. sefl[:format] is good.  
but i dont’ understand why it reported the error : “Attempt to call  
private method” in View page, when i called show action.

I know the column ‘format’ will be cause trouble. beacuse all of  
instance variable has the private method named ‘format’, right ?

## but why it is good as following :

## app/views/release/show.html.erb

**Movie:** \<%=h @release.movie\_id %\>

**Format:** \<%=h @release.format %\>

**Released on:** \<%=h @release.released\_on %\>

\<%= link\_to ‘Edit’, edit\_release\_path(@release) %\> |  
\<%= link\_to ‘Back’, releases\_path %\>

it is good . but when i changed \<%=h @release.movie\_id %\> to \<  
%=h @release.movie.title %\>, when i called show action , it  
reported a error :“Attempt to call private method”( this line: \<%=h  
@release.format %\>)

how can to explain it ? thank you.

---

<div class="post-metadata">

**Author:** ![SSSB9SfFSSB](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/2bfe46/32.png) [@SSSB9SfFSSB](https://www.ruby-forum.com/u/SSSB9SfFSSB)\
**Post date:** [December 19, 2008, 10:22am UTC](https://www.ruby-forum.com/t/rails2-2-2-is-it-a-bug/155752/8 "2008-12-19T10:22:05Z")

</div>

you can read \<Agile Web D. With Rails 3rdEdition\>

---

<div class="post-metadata">

**Author:** ![SSSB9SfFSSB](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/2bfe46/32.png) [@SSSB9SfFSSB](https://www.ruby-forum.com/u/SSSB9SfFSSB)\
**Post date:** [December 19, 2008, 10:20am UTC](https://www.ruby-forum.com/t/rails2-2-2-is-it-a-bug/155752/9 "2008-12-19T10:20:19Z")

</div>

why i can call format in this page:

* * *

## app/views/release/show.html.erb

**Movie:** \<%=h @release.movie\_id %\>

**Format:** \<%=h @release.format %\>

**Released on:** \<%=h @release.released\_on %\>

\<%= link\_to ‘Edit’, edit\_release\_path(@release) %\> |  
\<%= link\_to ‘Back’, releases\_path %\>

it is good! format can be call . why ?

I’m really confused!
