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

  • SEARCH
  • Home
  • 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 7840423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T15:46:42+00:00 2026-06-02T15:46:42+00:00

def add if params[:note_add] == Add Note.create({:user_id => @user[id], :note_type => params[:type], :text =>

  • 0
def add
    if params[:note_add] == "Add"
      Note.create({:user_id => @user["id"], :note_type => params[:type], :text => params[:note_text], :lng => params[:lng], :lat => params[:lat]})
    end
  end

I am new on Ruby on Rails and I am trying to get data from database. How could i do it?

  • 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-02T15:46:43+00:00Added an answer on June 2, 2026 at 3:46 pm

    If you are using a relation DB like MySQL, Postgres or other you should use Active Record that RoR brings. It’s a ORM and provides plenty of functionalities for interacting with DB, and it seems your are already using it. For querying data check this page on the guides.
    http://guides.rubyonrails.org/active_record_querying.html

    Some examples

    Note.find(1) #get note with id=1
    Note.find_by_note_type("sometype") #gets first found with note_type="sometype" (I think so)
    Note.where("note_type = ?", "sometype") #gets all notes that have note_type="sometype"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

def update @album = Album.find(params[:id]) if @album.update_attributes(params[:album]) redirect_to(:action=>'list') else render(:action=>'edit') end end A Rails
def add_like user_id $redis.sadd likes:#{_id}, user_id end def remove_like user_id $redis.srem likes:#{_id}, user_id end
this is my method def add @result @log = Log.new(params[:log]) if @log.save result =
def create msg = current_user.msgs.build(params[:msg]) msg.message = msg.message msg.created_at = Time.now # HACK if
def initialize(apps, catch=404) @apps = []; @has_app = {} apps.each { |app| add app
On 2.7.5.final, I'm attempting to add a Iterable list of Ints like so def
def test_method [a, b, c].map {|i| yield(i) } end If I call test_method like
def any? if block_given? method_missing(:any?) { |*block_args| yield(*block_args) } else !empty? end end In
def foo(**args): for k, v in args.items(): print type(k), type(v) for k, v in
I have an action like this: def add_credit_card if request.post? unless params[:conditions] flash[:error] =

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.