# Splitting up data for input (multiple controllers one model?

**URL:** <https://www.ruby-forum.com/t/splitting-up-data-for-input-multiple-controllers-one-model/131160>\
**Category:** Rails\
**Created:** [March 6, 2008, 3:23pm UTC](https://www.ruby-forum.com/t/splitting-up-data-for-input-multiple-controllers-one-model/131160 "2008-03-06T15:23:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![confundido](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/90ced4/32.png) [@confundido](https://www.ruby-forum.com/u/confundido)\
**Post date:** [March 6, 2008, 3:23pm UTC](https://www.ruby-forum.com/t/splitting-up-data-for-input-multiple-controllers-one-model/131160/1 "2008-03-06T15:23:15Z")

</div>

hi,

I have a model detailing companies and i would like to split up the data  
entry into different views.

for instance company profile, contact etc.

so they can create a company then edit the various field using different  
views. I assumed the best way to do this is create a controller for  
each view?

I have tried this with profile but i get no joy, it won’t update the  
records attributes but throws no errors, it does populate the fields  
with existing data in the edit view so edit action is correct.

here’s my code

have tried error\_messages\_for to :profile or :company but i get no  
errors

#views/profiles/edit.html.erb  
\<%= error\_messages\_for :profile %\>

\<% form\_for :profile do |f| %\>

Profile  
\<%= f.text\_area :profile, :cols =\>"80", :rows =\> "20" %\>

\<%= f.submit 'Update' %\>

\<% end %\>

class ProfilesController \< ApplicationController  
before\_filter :login\_required

# GET /profiless/1/edit

def edit  
@profile = Company.find(@current\_company.id)  
end

# PUT /profiles/1

# PUT /profiles/1.xml

def update  
@profile = Company.find(params[:id])

```
respond_to do |format|
  if @profile.update_attributes(params[:company])
    flash[:notice] = 'profile was successfully updated.'
    format.html { redirect_to(@profile) }
    format.xml { head :ok }
  else
    format.html { render :action => "edit" }
    format.xml { render :xml => @profile.errors, :status =>

```

:unprocessable\_entity }  
end  
end  
end

cheers  
Nathan

---

<div class="post-metadata">

**Author:** ![confundido](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/90ced4/32.png) [@confundido](https://www.ruby-forum.com/u/confundido)\
**Post date:** [March 6, 2008, 3:28pm UTC](https://www.ruby-forum.com/t/splitting-up-data-for-input-multiple-controllers-one-model/131160/2 "2008-03-06T15:28:43Z")

</div>

> ```
> if @profile.update_attributes(params[:company])
> 
> ```

ps this line should read :profile not :company. still doesn’t work  
though 🙂

---

<div class="post-metadata">

**Author:** ![confundido](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/90ced4/32.png) [@confundido](https://www.ruby-forum.com/u/confundido)\
**Post date:** [March 6, 2008, 5:13pm UTC](https://www.ruby-forum.com/t/splitting-up-data-for-input-multiple-controllers-one-model/131160/3 "2008-03-06T17:13:03Z")

</div>

On 6 Mar 2008, at 14:23, Nathan S. wrote:

> Profile  
> \<%= f.text\_area :profile, :cols =\>"80", :rows =\> "20" %\>

This implies the data will be in params[:profile]

> ```
> if @profile.update_attributes(params[:company])
> 
> ```

but here you’re using params[:company]

Fred

---

<div class="post-metadata">

**Author:** ![confundido](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/90ced4/32.png) [@confundido](https://www.ruby-forum.com/u/confundido)\
**Post date:** [March 6, 2008, 5:14pm UTC](https://www.ruby-forum.com/t/splitting-up-data-for-input-multiple-controllers-one-model/131160/4 "2008-03-06T17:14:48Z")

</div>

On 6 Mar 2008, at 16:12, Frederick C. wrote:

> > \<% form\_for :profile do |f| %\>
> > 
> > Profile  
> > \<%= f.text\_area :profile, :cols =\>"80", :rows =\> "20" %\>
> 
> This implies the data will be in params[:profile]
> 
> > ```
> > if @profile.update_attributes(params[:company])
> > 
> > ```
> 
> but here you’re using params[:company]

Oops, hadn’t read your second mail 🙂

Sorry
