Skip to content

New querying style in draft:resource #91

@raghubetina

Description

@raghubetina

Let's update draft:resource to use the new style for querying that we've been using in class: first put the Whatever::ActiveRecord_Relation in a variable called matching_whatevers, then proceed to do an .at(0) or .order to produce the instance variable.

def index
  matching_whatevers = Whatever.all

  @list_of_whatevers = matching_whatevers.order({ :created_at => :desc })

  render({ :template => "whatever_templates/index.html.erb" })
end
def show # edit, update, destroy
  the_id = params.fetch("path_id")

  matching_whatevers = Whatever.where({ :id => the_id })

  @the_whatever = matching_whatevers.at(0)

  render({ :template => "whatever_templates/show.html.erb" })
end

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions