# Stray questions

**URL:** <https://www.ruby-forum.com/t/stray-questions/150924>\
**Category:** Rails\
**Created:** [October 14, 2008, 11:08pm UTC](https://www.ruby-forum.com/t/stray-questions/150924 "2008-10-14T23:08:56Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![peterkemp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/90db22/32.png) [@peterkemp](https://www.ruby-forum.com/u/peterkemp)\
**Post date:** [October 14, 2008, 11:08pm UTC](https://www.ruby-forum.com/t/stray-questions/150924/1 "2008-10-14T23:08:56Z")

</div>

Hi,

I’ve been googling and going through the forum, and I can’t find the  
answers so some stray questions.

A) If I have a render :partial is there a way to get rid of the trailing  
newline? \<%- and -%\> don’t work. Is the   
 an essential part of the  
partial?

B) People say that the mysql tables get kinda messy sometimes and that  
they  
need to be reinitialized every once in a while. Frankly, that kind of  
talk scares me. But what are the steps for reinitializing?

I have a problem where I added the has\_many and belongs\_to lines fairly  
late in the game, and I am worried that somehow the scaffolding isn’t  
paying attention to them. I have an object that has\_many As and  
has\_many Bs. It gives me no problem with the As, but when it tries to  
find the Bs, give an error.

The error says:

uninitialized constant SpreadType::Abstractleg

I don’t have any irritating pluralization or nothin.

I am running on Debian Linux.

1. I also get a scary error when I try to install the ruby-gems  
debugging package. Should I just switch OSes? What is the VERY BEST OS  
for doing ruby work?

---

<div class="post-metadata">

**Author:** ![peterkemp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/90db22/32.png) [@peterkemp](https://www.ruby-forum.com/u/peterkemp)\
**Post date:** [October 14, 2008, 11:19pm UTC](https://www.ruby-forum.com/t/stray-questions/150924/2 "2008-10-14T23:19:16Z")

</div>

See inline - I’ll do my best to answer.

On Tue, Oct 14, 2008 at 4:08 PM, Peter K. \<  
removed\_email\_address@domain.invalid\> wrote:

> Hi,
> 
> I’ve been googling and going through the forum, and I can’t find the  
> answers so some stray questions.
> 
> A) If I have a render :partial is there a way to get rid of the trailing  
> newline? \<%- and -%\> don’t work. Is the   
> an essential part of the  
> partial?

trainling newline? like in your source code? or when you look at the  
page?

> B) People say that the mysql tables get kinda messy sometimes and that  
> they  
> need to be reinitialized every once in a while. Frankly, that kind of  
> talk scares me. But what are the steps for reinitializing?

I have no idea. Hasn’t really been a problem here. Sounds like FUD.  
However  
you don’t have to use MySQL.  
You can use PostgreSQL, Oracle, MS Sql Server, whatever works best for  
you.

> I have a problem where I added the has\_many and belongs\_to lines fairly  
> late in the game, and I am worried that somehow the scaffolding isn’t  
> paying attention to them.

Scaffolding doesn’t care about associations, and it’s really not meant  
to be  
anything but a learning tool.

> I have an object that has\_many As and  
> has\_many Bs. It gives me no problem with the As, but when it tries to  
> find the Bs, give an error.
> 
> The error says:
> 
> uninitialized constant SpreadType::Abstractleg
> 
> I don’t have any irritating pluralization or nothin.

Show your code - both models with names and associations, and also your  
database table names and field names for both.

Generally, if project has\_many :tasks, and task belongs\_to :project,  
then  
the tasks table would have a project\_id column. The belongs\_to  
declaration  
goes in the model whose table contains the foreign key.

> I am running on Debian Linux.
> 
> 1. I also get a scary error when I try to install the ruby-gems  
> debugging package. Should I just switch OSes? What is the VERY BEST OS  
> for doing ruby work?

Debian is a fine OS, but I don’t know how you installed things. Its  
packages  
for Ruby might be out of date. Ubuntu is a good distro for development.  
I’ve  
used Ubuntu, Windows, and Mac, and I prefer the Mac OS for Rails  
development. Not going to get into the reasons because I don’t want to  
start  
a holy war. But given that your installation has recent versions of Ruby  
(ruby -v should report 1.8.4 or higher, preferably something in 1.8.6 or  
so)  
then you should be fine.

---

<div class="post-metadata">

**Author:** ![peterkemp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/90db22/32.png) [@peterkemp](https://www.ruby-forum.com/u/peterkemp)\
**Post date:** [October 15, 2008, 12:08am UTC](https://www.ruby-forum.com/t/stray-questions/150924/3 "2008-10-15T00:08:59Z")

</div>

And here is the index file

\<% for spread\_type in SpreadType.find\_spread\_names%\>  
\<%= spread\_type.name %\>

```
<%

# this loop works

for customer_subscription in spread_type.customer_subscriptions
   %> <%= customer_subscription.customer_id %>
   <%
end

```

# this loop does not work

# for ghostleg in spread\_type.ghostlegs

# 

# end

%\>

```
<% end %>
```

---

<div class="post-metadata">

**Author:** ![peterkemp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/90db22/32.png) [@peterkemp](https://www.ruby-forum.com/u/peterkemp)\
**Post date:** [October 14, 2008, 11:51pm UTC](https://www.ruby-forum.com/t/stray-questions/150924/4 "2008-10-14T23:51:32Z")

</div>

> trainling newline? like in your source code? or when you look at the  
> page?

On the page. I guess what I am trying to do is have an update in a  
division using a partial, with multiple divisions on the same line.

```
render :update do |page|
    page[:test].replace_html :partial => 'pretty'
    page[:test2].replace_html :partial => 'reptiles'
      end

```

A friend of mine who is a mid-level rails developer thinks it might be  
impossible to avoid the breaks.

> Show your code - both models with names and associations, and also your  
> database table names and field names for both.

Here is the parent

class SpreadType \< ActiveRecord::Base

has\_many :spreads  
has\_many :customer\_subscriptions  
has\_many :ghostlegs  
has\_many :abstractlegs

def index

end  
def self.find\_spread\_names

```
find (:all)

```

end  
end

Here is the child that works:

class CustomerSubscription \< ActiveRecord::Base  
belongs\_to :customer  
belongs\_to :underlying  
belongs\_to :spread\_type  
end

Here is the child that doesn’t work

class Ghostlegs \< ActiveRecord::Base  
belongs\_to :spread\_type  
end

Here is the creation code for the child that doesn’t work:

class CreateGhostlegs \< ActiveRecord::Migration  
def self.up  
create\_table :ghostlegs do |t|  
t.decimal :daystoexpire  
t.decimal :distancefromunderlying  
t.decimal :abstractratio  
t.integer :corp  
t.integer :spread\_type\_id

```
  t.timestamps
end

```

end

def self.down  
drop\_table :ghostlegs  
end  
end

And here is the migration code for the parent

class CreateSpreadTypes \< ActiveRecord::Migration  
def self.up  
create\_table :spread\_types do |t|  
t.string :name

```
  t.timestamps
end

```

end

def self.down  
drop\_table :spread\_types  
end  
end

So maybe the underscore in the table name is what’s confusing things?  
Or is that just FUD logic? Why does it work for one and not the other?  
Shouldn’t it just generate the queries?

---

<div class="post-metadata">

**Author:** ![peterkemp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/90db22/32.png) [@peterkemp](https://www.ruby-forum.com/u/peterkemp)\
**Post date:** [October 15, 2008, 12:16am UTC](https://www.ruby-forum.com/t/stray-questions/150924/5 "2008-10-15T00:16:14Z")

</div>

On Oct 14, 10:51 pm, Peter K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> class SpreadType \< ActiveRecord::Base
> 
> has\_many :spreads  
> has\_many :customer\_subscriptions  
> has\_many :ghostlegs  
> has\_many :abstractlegs

[snip]

> class Ghostlegs \< ActiveRecord::Base  
> belongs\_to :spread\_type  
> end

has\_many :ghostlegs will be looking for a class class Ghostleg in  
ghostleg.rb (similarly for abstractlegs)

Fred

---

<div class="post-metadata">

**Author:** ![peterkemp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/90db22/32.png) [@peterkemp](https://www.ruby-forum.com/u/peterkemp)\
**Post date:** [October 15, 2008, 12:18am UTC](https://www.ruby-forum.com/t/stray-questions/150924/6 "2008-10-15T00:18:35Z")

</div>

On Tue, Oct 14, 2008 at 2:51 PM, Peter K.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> On the page. I guess what I am trying to do is have an update in a  
> division using a partial, with multiple divisions on the same line.

If you’re talking about a

 tag, it’s a block-level element. If you  
want multiple divs side-by-side, you’ll need to use the appropriate  
CSS to position them that way.

> A friend of mine who is a mid-level rails developer thinks it might be  
> impossible to avoid the breaks.

Rails does wonderful stuff, but it doesn’t absolve _web_ developers  
from the need to know HTML and CSS.

## FWIW,

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

---

<div class="post-metadata">

**Author:** ![peterkemp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/90db22/32.png) [@peterkemp](https://www.ruby-forum.com/u/peterkemp)\
**Post date:** [October 15, 2008, 1:02am UTC](https://www.ruby-forum.com/t/stray-questions/150924/7 "2008-10-15T01:02:09Z")

</div>

Thank you fred: That was it.

I had created it with the plural, and then was treating it as though I  
had created it with the singular.

If you’re ever in Chicago, I’ll buy you lunch.

---

<div class="post-metadata">

**Author:** ![peterkemp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/90db22/32.png) [@peterkemp](https://www.ruby-forum.com/u/peterkemp)\
**Post date:** [October 15, 2008, 1:03am UTC](https://www.ruby-forum.com/t/stray-questions/150924/8 "2008-10-15T01:03:37Z")

</div>

And thanks for the reality check, Hassan & Brian.

This really is a very helpful forum. Thanks…
