0

I'm a Rails beginner and currently attempting to make a web application where a user may be shown an array of cards and is able to swipe each card either left or right. I found Gajus/Swing which gave me a great-looking swipeable cards interface in its example "card-stack".

Now, while I'm able to run a rails server with the functional interface (I can drag cards from the stack), I have no clue how to keep record of which card was swiped to which direction in the backend (Rails/ActiveRecord). How does the backend work when integrating this JavaScript interface with Rails?

Please ask me to clarify anything if needed. Any help is appreciated

PS: I'm asking here because I figure this is more a general question about JavaScript+Rails than the one about the Swing interface itself.

1
  • you know jquery and ajax ? I think you can do a ajax post in every swipe javascript event. Commented Nov 24, 2016 at 21:55

1 Answer 1

1

(Caveat, haven't touched Rails since 3.2)

You're starting from the bottom up, to need to think from the top down.

You need to go through the rails 'hello world' example get the 'Welcome to Rails' page up. It will be contained in index.html in your rails app.

First find it, then compare it to your current index.html (or whatever) and see how to make the rails app render your example.

You'll need to learn about where your css and javascript goes within the rails framework, (hint they are considered assets) because rails will serve it up to your page.

Then you've got to build something on the back end with Rails that does whatever work is needed. At the very least you'll need to create a controller with at least one action (method). That action would possible record swipes?

Then, the very LAST thing you'll do is figure out how to call that Rails controller->action via Javascript.

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.