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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:11:45+00:00 2026-06-17T05:11:45+00:00

I am following this video http://railscasts.com/episodes/258-token-fields-revised and i implement this also sucessfully. But now

  • 0

I am following this video http://railscasts.com/episodes/258-token-fields-revised and i implement this also sucessfully. But now i am using namespace.
I have lends_controller inside folder employee inside asset folder.
this is my model of lend controller

class Employee::Asset::Lend
  include Mongoid::Document
  include Mongoid::Timestamps
  field :name, type: String
  field :text, type: String
  field :date
  field :asset_tokens
  field :user_id, type: String
  has_and_belongs_to_many :assets
  belongs_to :tags
def asset_tokens=(tokens)
 self.asset_ids = Asset.ids_from_tokens(tokens)
 end
end

Now i have another model asset. There i have to define has and belongs to this lend model also I did this

class Asset
  include Mongoid::Document
  field :name, type: String
  field :description, type: String
  field :serial_number, type: String
  field :status, type: Integer
  field :tag_tokens
  field :quantity, type: Integer
  validates_presence_of :name 
  validates :serial_number,:uniqueness => true

  has_and_belongs_to_many :employee_asset_lends
  has_and_belongs_to_many :tags

  def self.tokens(query)
   assets = where(name: /#{Regexp.escape(query)}/i)


  end

form for lend controller is

<%= f.label :asset_tokens, "Assets" %>
  <%= f.text_field :asset_tokens, data: {load: @employee_asset_lend.assets}%><br>
  <%= f.input :date,:input_html => { :class => "dp1"},:label=> "Lend Date"%>

inside coffescript file for lend.js.coffee

jQuery ->
  $('#employee_asset_lend_asset_tokens').tokenInput '/assets.json'
    theme: 'facebook'
    prePopulate: $('#employee_asset_lend_asset_tokens').data('load')

But it gives error uninitialized constant EmployeeAssetLend from asset views.
and from lend view it gives error like undefined methodall_of’ for Employee::Asset:Module`

  • 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-17T05:11:46+00:00Added an answer on June 17, 2026 at 5:11 am

    pleaes check the right way to make HABTM-has_and_belongs_to_many Assosiation for more details

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

Sidebar

Related Questions

I'm following this video tutorial and learning how to create authentication from scratch: http://www.youtube.com/watch?v=O5RDisWr_7Q
For example, I have the following string: var string = 'watch this video http://vimeo.com/8122132
I was following this video: http://www.youtube.com/watch?v=Y63vq_tcTGk and at 8:20 he types ds.Add(a); show_diem(); however
I'm embeding this video http://www.youtube.com/watch?feature=player_embedded&v=kzsBCriOrh8 on a site but I'm getting a square aspect
I tried to create this by following the video at http://www.asp.net/learn/videos/video-7026.aspx where Joe Stagner
Following this code my button works perfectly: http://twitter.github.com/bootstrap/javascript.html#modals Fades and everything. I want to
I am following the video on this page http://zegoggl.es/2009/12/building-android-apps-in-scala-with-sbt.html which use SBT to create
I followed along with Ryan Bates' authenticating with Facebook Railscast http://media.railscasts.com/assets/episodes/videos/360-facebook-authentication.ogv in which he
Using the help of the following youtube video http://www.youtube.com/watch?v=ePuCsvwoHMo I would like to get
I have the following code, obtained from http://jakearchibald.com/scratch/alphavid/ $(#video).append('<video id=movie style=display:none autobuffer><source id=srcMp4 src=https://host-away-from-host.com/file.mp4

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.