410 Experience
1 Lesson Completed
0 Questions Solved


Posted in Multiple forms one submit.

Hi there!

I've a view that needs to generate a form table, based on clients and days. For 7 days it creates

View (i've tried to do
<%= form_for @effort, data: {remote: true} do |f| %>
<% do |client| %>

<%= %>

    <%  @days.each do |day| %>

    <th style="" colspan="2">
    <%= render 'home/dashboard/form', :user => current_user, :client => client, :day => day  %>
    <% end %>
<% end %>

<% end %>

<%= button_tag "Save", id: "button-feedback-by-bullet", data: {controller: "effort", target: "effort", action: "effort#getdate" } %>

with Flatpickr i do select the date i need and with this JS I do modify the ID and the classname of HTML elements to be able to generate individual input fields

generateDates (a){

console.log("data generateDates: " + a)
this.numArray = new Array(7);

for (var i = 0; i < this.numArray.length; i++) {
  var dateParsed = Date.parse(a).add(-[i]).day()
  var dateToload = Date.parse(dateParsed).toString('dd/MM/yyyy')
  this.header = new Array()
  var header = document.getElementsByClassName('dateTodayEffort-'+[i])
  document.getElementById('dateToday-'+[i]).innerHTML = dateToload

var ar_header = header.length;

for (var n = 0; n < ar_header; n++) {
header[n].value = dateToload


let forms = document.getElementsByTagName('form');
for (let index = 0; index < forms.length; ++index) {
var formId = 'form'+[index]
forms[index].id = formId





def create
@effort =

  if @effort.effort_time = nil


 respond_to do |format|
    format.html { redirect_to dashboard_path , notice: 'Effort was successfully created.' }
    # format.json { render :show, status: :created, location: @effort }
    format.html { render dashboard
    format.json { render json: @effort.errors, status: :unprocessable_entity }

The problem i've is: once i do submit, it creates each input and do the redirect of each form

I would need to do some kinf of array of form data imput and once its saved then redirect or refresh page or whatever

any idea?

thanks in advance!

Posted in Stimulus - flatpickr

Hi all i've been trying to do one thing without sucess for few days...

i want to select a date on the flatpickr and then based on that date create a table

Date selected Date selected -1day Date selected -2day Date selected -3day Date selected -4day


import "flatpickr/dist/themes/dark.css";
export default class extends Flatpickr {

static targets = [ "output" ] <-- want to export the selected date on the flatpickr to the view

change(selectedDates, dateStr,instance) {
console.log (dateStr) <-- this prints out the date i select on the console.
this.outputTarget.textContent = dateStr <-- this should send the dateStr to the outputTarget but doesn't work neither here or on the XX
XX <-- if i put it here " this.outputTarget.textContent = dateStr" dateStr doesn't have content.

Any idea?

thanks all!

Posted in Help request - Not sure how to implement an idea.

Hi Ashley!, kind of. i'll try with a example :D

in the view it generates a list with the list of pills assigned to the person and when it writes on the box it automatically saves to db or draft the insert. that way is not necessary to do a button for each row.

    today -5    today -4  today-3 today-2  today -1 Today

Pill A |1 _| |___| |2| |____| || |___|

    today -5    today -4  today-3 today-2  today -1 Today

Pill B |____| |3| |_____| |1| |_| |___|


Posted in Help request - Not sure how to implement an idea.

Hi, first of all thanks all for reading this :)

Let's say i would implement a kind of autosave form based on a calendar.

Let's sayt for each row of elements (pills) you have the last 7 days from the actual date columns, in every day there is a form field where you can input the amount of pills you have taken, and when you write down the number 2 5 8 it automatically writes down to db

prescription.create(Pill id X, date: xxx.xxxx, amount: xx)

i'm looking the autosave episode, but i'm kind of lost about the calendar option...

not sure if i've explained myself correctly :D

thanks all!

Posted in Best way to start a rails project?

Just tryied to start with rails 6 beta 2, but i'm using Aws cloud9 and sqlite 3.8 (requiered by rails) is not installed, and havent been able yet to install / upgrade version. :/

Posted in Best way to start a rails project?

thanks Matt, i'll give it a try

by now i'm trying to have a good start planning in advance models and features i want to implement.

many thanks!


Posted in rails 5.2.2 template.rb sqlite3 versions issue

Hi there, after few hours digging arround i just found the answer to this:

when trying to start a new project with the template.rb i had issues because of the version of sqlite3. rails was automatically using 1.3.6 active record 5.2.2 forces it and the template was installing the 1.4.0 so had to change manually,

Seems it was a bug reported and already merged to the 5.2.3 so next version this post will (hopefully) make no sense :)

.rvm/gems/ruby-2.6.0/gems/activerecord-5.2.2/lib/active_record/connection_adapters $ vi sqlite3_adapter.rb


gem "sqlite3", "~> 1.3.6"
gem "sqlite3", "~> 1.4.0"

and it was able to finish the creation of the new app

Hope it helps!


Posted in Best way to start a rails project?

thanks Chris!

Posted in Best way to start a rails project?

Hi i've been coding with rails selflearning with videos books and so on, (prolly not the best way to do it) but i'm wondering if there are few best practices to follow up.

For instance, when i do start a new project i spend lot of time cheching if it's worth or not to do gems for authentication, maybe in the future are obsolete or non supported? or when rails 6 arrives then code will break and maybe not being able to fix it?

is better to start with the models then the controllers? not sure if youll understandme :) but thanks for reading :D

Posted in Dynamic Nested Forms with Stimulus JS Discussion

then what way you'd suggest to follow up tutorials? cloning the project?

Posted in Dynamic Nested Forms with Stimulus JS Discussion

Hey there! first comment here, trying to follow up the tutorial but missing the template.rb file you're using to start the project... i'm quite sure missing something basic :)

can someone help?