Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7910343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T12:50:08+00:00 2026-06-03T12:50:08+00:00

In my contactlist CRUD application, all the contacts are shown properly when i type

  • 0

In my contactlist CRUD application, all the contacts are shown properly when i type the following URL: localhost/contact

However, I want to have two options for each contact- either to update the information or to delete the record. So once i click on contact,say- “Chetan”, i want to go to a ‘showmain’ page with two options- Update(linking me to an update page) and Delete(linking me to a del page).

My controller is as follows:-

class ContactController < ApplicationController

  def index
    @contacts=Contact.find(:all)

      respond_to do |format|
      format.html # index.html.erb
      format.json { render json: @contacts }
    end
  end


  def show
    @contact=Contact.find(params[:id])
  end

  def del
    @contact=Contact.find(params[:id])
  end

  def new
    @contact=Contact.new
  end

  def create
     @contact=Contact.new(params[:contact])
    if @contact.save!
      redirect_to :action => "index"
    else
      render :action => "new"
    end
  end

  def showmain

      respond_to do |format|
      format.html # index.html.erb
      format.json 
  #  @contact=Contact.new(params[:contact])
  end

  def update
    @contact=Contact.find(params[:id])
    @contact.attributes= params[:contact]
    @contact.save!
    redirect_to :action => "index" 
  end

  def delete
    @contact=Contact.find(params[:id])
    @contact.destroy
    redirect_to :action => "index"
  end
  end
  end

And my showmain.html.erb page where i am getting the syntax error(showmain.html.erb:14: syntax error, unexpected keyword_ensure, expecting $end) is as follows:-

<h1>Do you want to Update or Delete the Attributes? </h1>

<ul>
    <li>
        <%= link_to "Update" ,:action=>'show',:id => @contact -%>
    </li>

    <li>
        <%= link_to "Delete" ,:action=>'del',:id => @contact -%>
    </li>   
</ul>
<% end %>

<p>
    <%= link_to "Back", {:action => 'index'} -%>
</p>

Need some help to remove the error..

My show.html.erb is as follows:-

<h1>View/Edit Contact</h1>

 <% link_to "Update" , contact_path(@contact) do |f| -%

  <%= f.label :first_name %>:
  <%= f.text_field :first_name %><br />

  <%= f.label :last_name %>:
  <%= f.text_field :last_name %><br />

  <%= f.label :address %>:
  <%= f.text_field :address %><br />


  <%= f.label :city %>:
  <%= f.text_field :city %><br />


  <%= f.label :state %>:
  <%= f.text_field :state %><br />


  <%= f.label :country %>:
  <%= f.text_field :country %><br />


  <%= f.label :phone %>:
  <%= f.text_field :phone %><br />


  <%= f.label :email %>:
  <%= f.text_field :email %><br />

  <%= f.submit "Update" %>

<% end %>

<p>
    <%= link_to 'Back', {:action => 'index'} %>
</p>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T12:50:10+00:00Added an answer on June 3, 2026 at 12:50 pm
    def showmain
    
      respond_to do |format|
          format.html # index.html.erb
          format.json 
          #  @contact=Contact.new(params[:contact])
      end #Close respond_to
    end # Close the showmain
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

$.ajax({ type: POST, url: ContactList.asmx/GetContacts, data: {'start': + 1 + }, contentType: application/json; charset=utf-8,
i have created one listview.now i want to show data(contact no.,name) from contactlist of
I have contact list and I want to send an sms using MFMessageComposeViewController and
I have a class of following details: Public Class Contact Public prime As ContactPrime
Can we access all the email IDs for each contact from the iPhone contactlist
I want to add the selected contacts on a listview in my application .I
I am using google contact data objective c APIs for fetching contacts. I got
I want to add new contact to WP's contact list with C# code. but
I have three models: System_Contact System Contact_list The Contact_List model has two fields: contact
I'm building a simple Contact Management app with Crud using AngularJS 1.0.0rc8. Getting a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.