Vikram Sharma

Joined

440 Experience
3 Lessons Completed
0 Questions Solved

Activity

Posted in How to use ActionText in Rails 6 Discussion

Great tutorial Chris,

I could not get the image preview centre aligned till I changed my css to the following

.```
// actiontext.scss
form-control {

.attachment--content {
margin: 0.6em 0;
}

.attachment--content {
width: 100%;
text-align: center;
}

.attachment {
display: inline-block;
position: relative;
max-width: 100%;
margin: 0;
padding: 0;
}
}

Hi Chris,

Another concern is the location of custom javascript. I am new to Rails so please excuse my ignorance.
In Rails 5 we would add custom js to their own .coffee files. For Blog model I would write custom js in blog.coffee file and so on.
In Rails 6 all javascript gets added to a single file i.e application.js
How can I keep them seggregated?

Posted in TypeError: $(...).chosen is not a function

I am using Rails 6. I have installed jQuery, Bootstrap, & Popper as explained in one of the videos and Bootstrap is working fine. Now I have to use Chosen jQuery plugin.

I installed it using Yarn

yarn add ssh://[email protected]:harvesthq/chosen.git#7149a2aed86d4d815f1497f27ae602ed898b9b02

which outputted

yarn add v1.15.2
[1/4] Resolving packages...
[2/4] Fetching packages...
info [email protected]: The platform "linux" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning " > [email protected]" has unmet peer dependency "[email protected]^4.0.0".
warning "webpack-dev-server > [email protected]" has unmet peer dependency "[email protected]^4.0.0".
[4/4] Building fresh packages...
success Saved lockfile.
success Saved 1 new dependency.
info Direct dependencies
└─ [email protected]
info All dependencies
└─ [email protected]
Done in 158.62s.
In environment.js I added
environment.plugins.append(
  "Provide",
  new webpack.ProvidePlugin ({
    $: 'jquery',
    jQuery: 'jquery',
    Popper: ['popper.js', 'default'],
    Chosen: ['chosen.js', 'default']
  })
)

In my application.js I have

document.addEventListener("turbolinks:load", () => {
  $('[data-toggle="tooltip"]').tooltip()
  $('[data-toggle="popover"]').popover()
  $("#course_instructor_ids").chosen()
})

Which gives me the error (in web console)

TypeError: $(...).chosen is not a function[Learn More]

If I add the following to application.js

import chosen from "chosen"

I get

Error: Cannot find module 'chosen'

Any help will be life saving :)

Try Chris's hatchbox.io
I have seen the "How it Works Video" and I am very impressed. I am not a dev op guy and not very comfortable with Capistrano and Chef. I have multiple Rails Apps to manage and I think Hatch will do a lot of "dev op" work for me leaving me with time to focus on shipping products (I do an app every couple of months or so and a major app every 6 months to a year."
I am hoping Chris offers his GoRails subscribers a discount coupon ;)
Regards
Vikram

Thanks for the help buddy.

Hi,

I want to create a web app which is a simple HR SaaS. Each user/company which registers will have get a separate table to upload list of employees. In terms of autorization a user/company can access only their table.

It is possible/advisible to take this approach in Rails i.e.

  1. A user can create their own table in database
  2. User can modify columns of the database

Thanks for the help.
Regards
Vikram

logo Created with Sketch.

Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

© 2020 GoRails, LLC. All rights reserved.