# MVC... Issues with Models (2nd attempt at post...previous lo

**URL:** <https://www.ruby-forum.com/t/mvc-issues-with-models-2nd-attempt-at-post-previous-lo/79733>\
**Category:** Rails\
**Created:** [December 18, 2006, 4:39pm UTC](https://www.ruby-forum.com/t/mvc-issues-with-models-2nd-attempt-at-post-previous-lo/79733 "2006-12-18T16:39:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![vinsonizer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/848f3c/32.png) [@vinsonizer](https://www.ruby-forum.com/u/vinsonizer)\
**Post date:** [December 18, 2006, 4:39pm UTC](https://www.ruby-forum.com/t/mvc-issues-with-models-2nd-attempt-at-post-previous-lo/79733/1 "2006-12-18T16:39:32Z")

</div>

I’m new to Ruby and RoR. I written a small app that has gotten my feet  
wet.

I have a question about Models. Controllers, I’m good. Views and  
Partials, I’m good.

Okay, so Models hold data. Models have the ability to query the  
database to access and change data. Model changes are only picked up  
after server restart unlike everybody else… what? Most of my changes  
seem to be here. My controllers just say go here next and show this  
view. The real work, validation, business logic, … all seems to be  
in the Models. One of the first things that got me interested in Ruby  
/ RoR was avoiding the recompile/restart world of Java/C#. So am I  
doing something wrong? It’s almost like I’m looking for MVCL (Model -  
DataLayer ONLY, View [Presentation], Controller, and Logic).

Thanks,  
Jason

---

<div class="post-metadata">

**Author:** ![vinsonizer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/848f3c/32.png) [@vinsonizer](https://www.ruby-forum.com/u/vinsonizer)\
**Post date:** [December 18, 2006, 4:53pm UTC](https://www.ruby-forum.com/t/mvc-issues-with-models-2nd-attempt-at-post-previous-lo/79733/2 "2006-12-18T16:53:34Z")

</div>

Jason V. wrote:

> Okay, so Models hold data. Models have the ability to query the  
> database to access and change data. Model changes are only picked up  
> after server restart unlike everybody else… what?

What? To change a model’s link to the database (correct me if I’m  
wrong) you edit stuff in db/migrate, run ‘rake migrate’ (?), run your  
tests (!), and hit your application’s pages. The new models are there.  
I do this all the time (with a SQLite backend for development).

To change a model’s class, I … change the class, run the tests, and  
hit the application’s pages. The changes are there. I frequently tweak  
code in any layer and instantly click on my pages’ links. The new  
action versions are all just there.

> Most of my changes  
> seem to be here.

That could be a design smell. Do most of your models’ methods reach  
out to other models?

> My controllers just say go here next and show this  
> view. The real work, validation, business logic, … all seems to be  
> in the Models. One of the first things that got me interested in Ruby  
> / RoR was avoiding the recompile/restart world of Java/C#. So am I  
> doing something wrong? It’s almost like I’m looking for MVCL (Model -  
> DataLayer ONLY, View [Presentation], Controller, and Logic).

Are you stopping and starting the server after each change? don’t do  
that.

Are you writing more unit tests than production code? Set your editor  
up to run such tests from one button.

(I remember my nightmare days with Tomcat, and I suspect that anyone  
burned by that gawd-awful system might have trouble thinking inside  
Rails’s capacious box!)

–  
Phlip  
[http://c2.com/cgi/wiki?ZeekLand](http://c2.com/cgi/wiki?ZeekLand) ← NOT a blog!!

---

<div class="post-metadata">

**Author:** ![vinsonizer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/848f3c/32.png) [@vinsonizer](https://www.ruby-forum.com/u/vinsonizer)\
**Post date:** [December 18, 2006, 5:05pm UTC](https://www.ruby-forum.com/t/mvc-issues-with-models-2nd-attempt-at-post-previous-lo/79733/3 "2006-12-18T17:05:35Z")

</div>

Hi –

On Mon, 18 Dec 2006, Jason Vogel wrote:

> I’m new to Ruby and RoR. I written a small app that has gotten my feet  
> wet.

Welcome!

> doing something wrong? It’s almost like I’m looking for MVCL (Model -  
> DataLayer ONLY, View [Presentation], Controller, and Logic).

What Rails environment are you running in? In development mode you  
should see everything, including models, getting reloaded. In  
production you’ll see very little reloading – but at that stage it  
shouldn’t matter.

David

–  
Q. What’s a good holiday present for the serious Rails developer?  
A. RUBY FOR RAILS by David A. Black ([Ruby for Rails](http://www.manning.com/black))  
aka The Ruby book for Rails developers!  
Q. Where can I get Ruby/Rails on-site training, consulting, coaching?  
A. Ruby Power and Light, LLC ([http://www.rubypal.com](http://www.rubypal.com))

---

<div class="post-metadata">

**Author:** ![vinsonizer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/848f3c/32.png) [@vinsonizer](https://www.ruby-forum.com/u/vinsonizer)\
**Post date:** [December 18, 2006, 9:48pm UTC](https://www.ruby-forum.com/t/mvc-issues-with-models-2nd-attempt-at-post-previous-lo/79733/4 "2006-12-18T21:48:28Z")

</div>

Hi –

On Mon, 18 Dec 2006, Jason Vogel wrote:

> > > doing something wrong? It’s almost like I’m looking for MVCL (Model -  
> > > aka The Ruby book for Rails developers!  
> > > activerecord (1.14.4.5618, 1.14.4)  
> > > Real simple on the service. I built about 20 [data] models. As I was  
> > > coding, I needed method “a” on model B. Write “a”, add call to “a”  
> > > from Controller and run. Controller would fire new code, but “a” would  
> > > not be found. Restart server, hit refresh on browser, method found.  
> > > My “mild” empirical evidence that models weren’t being reloaded.

Are these ActiveRecord::Base subclasses? I believe that if they’re  
not, they won’t automatically reload. You might have to put: include  
Reloadable in them.

(I could be out of date or out of sync on this, but it’s worth a try  
if that’s the case.)

David

–  
Q. What’s a good holiday present for the serious Rails developer?  
A. RUBY FOR RAILS by David A. Black ([Ruby for Rails](http://www.manning.com/black))  
aka The Ruby book for Rails developers!  
Q. Where can I get Ruby/Rails on-site training, consulting, coaching?  
A. Ruby Power and Light, LLC ([http://www.rubypal.com](http://www.rubypal.com))

---

<div class="post-metadata">

**Author:** ![vinsonizer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/848f3c/32.png) [@vinsonizer](https://www.ruby-forum.com/u/vinsonizer)\
**Post date:** [December 18, 2006, 9:22pm UTC](https://www.ruby-forum.com/t/mvc-issues-with-models-2nd-attempt-at-post-previous-lo/79733/5 "2006-12-18T21:22:23Z")

</div>

On Dec 18, 10:04 am, removed\_email\_address@domain.invalid wrote:

> > Okay, so Models hold data. Models have the ability to query the  
> > shouldn’t matter.
> 
> David
> 
> –  
> Q. What’s a good holiday present for the serious Rails developer?  
> A. RUBY FOR RAILS by David A. Black ([Ruby for Rails](http://www.manning.com/black))  
> aka The Ruby book for Rails developers!  
> Q. Where can I get Ruby/Rails on-site training, consulting, coaching?  
> A. Ruby Power and Light, LLC ([http://www.rubypal.com](http://www.rubypal.com))

Windows XP, SP2  
RadRails 0.72  
Development mode (technically, I not sure… )  
rails (1.1.6.5618, 1.1.6)  
actionmailer (1.2.5.5618, 1.2.5)  
actionpack (1.12.5.5618, 1.12.5)  
actionwebservice (1.1.6.5618, 1.1.6)  
activerecord (1.14.4.5618, 1.14.4)  
activesupport (1.3.1.5618, 1.3.1)

I’m not “raking” anything…  
I haven’t even started down the RoR test fixture path.

I wrote a little app that sends an email with a link. Open email,  
click link, return to 2nd controller, yea/nay, if yay, take payment,  
then final page, if nay, then final page. The final page does an  
update.

Real simple on the service. I built about 20 [data] models. As I was  
coding, I needed method “a” on model B. Write “a”, add call to “a”  
from Controller and run. Controller would fire new code, but “a” would  
not be found. Restart server, hit refresh on browser, method found.  
My “mild” empirical evidence that models weren’t being reloaded.

David,

Do you consult to Ruby/RoR resistant Enterprises :-)? I’m trying to  
convince management of the viability of Ruby/RoR in our JSP, Weblogic  
EJB world… Unfortunately, I’m not being overly successful.

Thanks,  
Jason
