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 7890787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:26:49+00:00 2026-06-03T06:26:49+00:00

I have a rails3.1 application where I will send some data to client. One

  • 0

I have a rails3.1 application where I will send some data to client. One way of doing it is a jscon call and then use jquery on client to add the json data to page. but I am sending a javascript code directly from view i.e, adding css classes and ids from view and just sending the annotated data to client.

something like this in js.erb file

$(“#posts”).append(” “);

$(“#posts”).data(‘totalPosts’, <%= @postCounter %>);

My question is Are there any potential issues with this approach? Any security risks or browser issues?

Thanks,
Anish

  • 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-03T06:26:51+00:00Added an answer on June 3, 2026 at 6:26 am

    It will work, but isn’t so great from a maintainability / system engineering point of view:

    • You’ll end up with fragments of jQuery javascript scattered amongst your view files.
    • You’ll probably have additional jQuery startup/bootstrapping code elsewhere.
    • You’re tightly coupling a dynamic web page (the client) to your server. Loose coupling is better.
    • You’re sending jQuery Javascript + data in response to a client user’s action. Better (and more compact) to just send the data.

    Suggestion: switch to an api. Make your Rails app into a service that serves up json. Write jQuery and regular Javascript on the client to interact with with the services provided by your Rails app.

    You can also use new compact libs on the browser that make this easy and fun. I’m liking AngularJS, for instance.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Do you have a working example of a Rails3 mvc application? How will it
I'm looking at building a Rails application which will have some pretty large tables
I'm writing a Rails application which will monitor data quality over some specific databases.
I have a rails application with User and Machine data models, as well as
I have a Rails application but after some time of development/debugging I realized that
I am building an application which will send status requests to users (via email
I need to create a form in my rails3 application that, when saved, will
I have a rails application where I would like to use both memcached and
I have a Rails application with several models-views-controllers which have some similar characteristics, for
I am experimenting with a design for a Rails application which will have most

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.