473,508 Members | 2,382 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

New to ruby (easy question i think)

6 New Member
Hello I am new at ruby on rails and have what i hope is a simple question. Say I have a DB with animal names and an id. I am using active scaffold. once I click on the edit to edit any animal name how can i then access that that name in the view? I want to be able to output it in the textbox name: as well as just display it below the textbox that active scaffold creates.

Thanks for the help
Oct 4 '07 #1
1 2231
asrinivas1234
4 New Member
Hello I am new at ruby on rails and have what i hope is a simple question. Say I have a DB with animal names and an id. I am using active scaffold. once I click on the edit to edit any animal name how can i then access that that name in the view? I want to be able to output it in the textbox name: as well as just display it below the textbox that active scaffold creates.

Thanks for the help
...................
u have to pass the id for the particular selected animal..

how can u do it?

in first page, u r displaying the animals right?
how do u display animals?
u r fetching from database in controller and assigning that object and inside the .rhtml page, u r catching that object and iterating that object and displaying the animals.
Ex:
in controller-->
@animals = Animal.find :all

inside view,
<%for animal in @animals%>
<% form_tag :action => 'edit', :id => animal.id do %>


<%end%>
<%= submit_tag 'edit' %>

have u seen the form statement,
:id => animal.id.

then, inside ur controllers edit method,
def edit
@animal = Animal.find(params[:id])
end

then,
inside ur 2nd rhtml page,
u can use @animal and print the corresponding data...

if u have doubt,
u can mail me, --> avasarala.asrinivas@gmail.com
Dec 17 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

8
3049
by: Useko Netsumi | last post by:
or perhaps Java for developing web application? I've develop a few applications using PHP/MySQL/Apache and its growing in size. After reading the Ruby tutorial, and do a simple script, I kind of...
54
6502
by: Brandon J. Van Every | last post by:
I'm realizing I didn't frame my question well. What's ***TOTALLY COMPELLING*** about Ruby over Python? What makes you jump up in your chair and scream "Wow! Ruby has *that*? That is SO...
13
2687
by: Wayne Folta | last post by:
I've been a long-time Perl programmer, though I've not used a boatload of packages nor much of the tacky OO. A couple of years ago, I decided to look into Python and Ruby. Python looked OK, but...
5
1756
by: F Jamitzky | last post by:
It is rather easy to define functions in python that mimic the special ruby syntactic sugar like: 5.times { print "Hello World!" } or .each { |food| eat food } In python these fragments...
5
1532
by: Ville Vainio | last post by:
I participated in a short thread on c.l.ruby, and had myself convinced that "blocks" might be a good idea. For bragging rights, if nothing else :). What I'm talking about is: <callable> block...
65
5457
by: Amol Vaidya | last post by:
Hi. I am interested in learning a new programming language, and have been debating whether to learn Ruby or Python. How do these compare and contrast with one another, and what advantages does one...
5
2313
by: Matias | last post by:
I'm not asking if it's better or not than php... I want to know the opinions of web developers about this new toy... Byee..
28
2955
by: john_sips_tea | last post by:
Just tried Ruby over the past two days. I won't bore you with the reasons I didn't like it, however one thing really struck me about it that I think we (the Python community) can learn from. ...
10
3764
by: lawrence k | last post by:
I work mostly in PHP, but at the web design firm where I work we are thinking of switching to Ruby on Rails. Our lead designer recently installed Typo on a client's site and he said to us, with...
9
2283
by: Erwin Moller | last post by:
Hi Group, This may seem a odd question in a PHP group, but I think this might be a good place to ask since I am mainly a PHP coder these days that maybe starts with Ruby. Situation: A client...
0
7231
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7336
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7405
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7066
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7504
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
3198
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1568
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
773
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
435
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.