0

I have one rails application App1 in which there is an Event section.But now I want that there should be a separate Rails App App2 for the Event.And a JS code, that will be used the App1 to fetch all the Event Lists,Event Creation etc.from the App2.

Yours suggestions are welcomed.

Please suggest me the approach for this.

Thanks, gsoni

1 Answer 1

2

If you have used scaffolding for the Event model in App1 then you can simply visit:

http://app1/events.json

and use:

$.getJSON('http://app1/events.json',function(data){
  $.each(data,function(k,v){
    /* Do something with each event */
  });
});

If you have not used scaffolding for the Event model in App then you simply need to create an action like so

def some_action
  @events = Event.all

  respond_to do |format|
    format.json { render json: @books }
  end
end

and use http://app1/controller_name/some_action.json in the above example.

The same principle works for creation, edits, etc. Just scaffold a model and use the default code to get an idea of how it works, and change accordingly.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.