# Getting specific values from params

**URL:** <https://www.ruby-forum.com/t/getting-specific-values-from-params/126293>\
**Category:** Rails\
**Created:** [January 17, 2008, 3:51am UTC](https://www.ruby-forum.com/t/getting-specific-values-from-params/126293 "2008-01-17T03:51:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![DVG](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/67e7ee/32.png) [@DVG](https://www.ruby-forum.com/u/DVG)\
**Post date:** [January 17, 2008, 3:51am UTC](https://www.ruby-forum.com/t/getting-specific-values-from-params/126293/1 "2008-01-17T03:51:14Z")

</div>

Sorry to post two newbie questions in one day 🙂

I’m trying to make a new Character row in my database. It has several  
values in the row, but I only need 2 or so from the user and the rest  
can be figured out by the app. My problem is I’m having trouble  
figuring out how to get a specific value from params.

For the record, I’m still in Rails 1.2.6.

So the form for the Character object should gather the Character’s  
codename, as well as the Character’s Power Level.

I want to gather the two paramters, do some calculations, and then  
actually do the creation, rather than having the user hard code all  
the values in a form and doing mass assignment.

So, the form I have now looks like this:  
\<% form\_tag(:action =\> ‘create’) do %\>  
\<%= text\_field ‘character’, ‘codename’ %\>  
\<%= text\_field ‘character’, ‘power\_level’ %\>  
\<%= submit\_tag “Create Character” %\>  
\<% end %\>

I expect my create method will contain something like this:  
character = Character.new do |c|  
c.codename = [Codename Parameter]  
c.power\_level = [Powerlevel Parameter]  
c.power\_points = [Powerlevel Parameter \* 15]  
…  
end

However, I can’t figure out how to retrieve the individual values  
brought over from the form.

---

<div class="post-metadata">

**Author:** ![DVG](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/67e7ee/32.png) [@DVG](https://www.ruby-forum.com/u/DVG)\
**Post date:** [January 17, 2008, 4:04am UTC](https://www.ruby-forum.com/t/getting-specific-values-from-params/126293/2 "2008-01-17T04:04:08Z")

</div>

I just thought that I might be overthinking it, and I would be able to  
do:  
character = params[:character]  
@codename = character.codename

But when I tried to print out @codename in a temporary view, it gave  
me an error for calling an undefined method.

---

<div class="post-metadata">

**Author:** ![DVG](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/67e7ee/32.png) [@DVG](https://www.ruby-forum.com/u/DVG)\
**Post date:** [January 17, 2008, 4:27am UTC](https://www.ruby-forum.com/t/getting-specific-values-from-params/126293/3 "2008-01-17T04:27:45Z")

</div>

Nevermind, I think I have it.

params[:character].fetch(‘codename’)

Seems to look right.
