Iam sorry i didnt get you… i have created a new action for the
ajax stuff is this approach wrong… This is how my states controller
is
class StatesController < ApplicationController
GET /states
GET /states.json
def index
@states = State.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @states }
end
end
GET /states/1
GET /states/1.json
def show
@state = State.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @state }
end
end
GET /states/new
GET /states/new.json
def new
@state = State.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @state }
end
end
GET /states/1/edit
def edit
@state = State.find(params[:id])
end
POST /states
POST /states.json
def create
@state = State.new(params[:state])
respond_to do |format|
if @state.save
format.html { redirect_to @state, notice: 'State was
successfully
created.’ }
format.json { render json: @state, status: :created, location:
@state }
else
format.html { render action: “new” }
format.json { render json: @state.errors, status:
:unprocessable_entity }
end
end
end
def countries_state
@state = State.find(“country_id = :c_id”,{:c_id => params[:country]})
respond_to do |format|
format.html
format.js
end
end
PUT /states/1
PUT /states/1.json
def update
@state = State.find(params[:id])
respond_to do |format|
if @state.update_attributes(params[:state])
format.html { redirect_to @state, notice: 'State was
successfully
updated.’ }
format.json { head :ok }
else
format.html { render action: “edit” }
format.json { render json: @state.errors, status:
:unprocessable_entity }
end
end
end
DELETE /states/1
DELETE /states/1.json
def destroy
@state = State.find(params[:id])
@state.destroy
respond_to do |format|
format.html { redirect_to states_url }
format.json { head :ok }
end
end
end
On Thu, May 3, 2012 at 5:20 PM, Aziz B.
[email protected]wrote:
resources :discounts
Make sure this route comes before the route entry for the country
var country_states_path = ‘/states/countries_state/’; however on
$.ajax({
the state_id that was selected currently. Using the below js, in your
success: function(data) {
Hi Hassan,
success: function(data) {
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
–
Thanks & Regards,
Akshar Jamgaonkar