rodolfo

Joined

180 Experience
0 Lessons Completed
0 Questions Solved

Activity

Posted in Select Or Create Field With Selectize.js Discussion

There exist any chance to create only by clic on enter key? I wan't to use the modal to submit/create a category.

Posted in How to complete a task via json using a check_box?

Hi guys,
I am new in this world of web development. I'm trying to mark a task as complete using a check_box, but I can't. Have you any ideas based on my code? Thank you in advance.

routes.rb

resources :commitments do
    resources :tasks  do
        member do
            patch :done
        end
    end
end

task_controller

def done
    @task = Task.find(params[:id])
    @task.update_attribute(:done, true)
end

done.js.erb

$('#task #task-<%= @task.id %>').html("<%= j render 'tasks/index' %>")

tasks/index (_index.js.erb)

<% @commitment.tasks.each do |task|%>
<div class="row" id="task-<%= task.id %>">
    <div class="form-group col">
        <span class="checklist-reorder">
            <i class="material-icons">reorder</i>
        </span>
        <div class="custom-control custom-checkbox col">

                        <!-- space for the check_box_tag -->
            <input type="checkbox" class="custom-control-input" id="checklist-item-<%= task.id %>" checked>
            <label class="custom-control-label" for="checklist-item-<%= task.id %>"></label>
            <div>
                <input type="text" placeholder="Checklist item" value="<%= task.name %>" data-filter-by="value" />
                <div class="checklist-strikethrough"></div>
                <%= link_to 'delete', commitment_task_path(@commitment.id, task), method: :delete, remote: true %>
            </div>
        </div>
    </div>
</div>
<% end %>

Posted in How to get param values through radio_buttons ?

Awesome! Thank you @jacob. I love this community.

Posted in How to get param values through radio_buttons ?

I'm trying to create a TARGET with a responsible user via form_with:

<div class="form-group-users">
    <% @users.each do |user| %>
        <div class="custom-control custom-radio">
            <%= f.radio_button :responsible_id ,'', id:"responsible-manage-#{user.id}", class:'custom-control-input' %>
            <label class="custom-control-label" for="responsible-manage-<%= user.id %>">
                <div class="d-flex align-items-center">
                    <%= image_tag user_avatar(user.id), class:'avatar mr-2', 'data-title' => user.first_name , 'data-toggle':'tooltip' %>
                    <span class="h6 mb-0" data-filter-by="text"><%= user.first_name %> <%= user.last_name %></span>
                </div>
            </label>
        </div>
        <% end %>
    </div>

The problem here is that params for responsible_id is empty.

Parameters: {"utf8"=>"✓", "authenticity_token"=>"+gh9H09zXkp+W0cUeZO12HDPgWHqWWcVsW+XxD/8o68srfQt/Od0MH/kYNYe6KxQZ2ncFDVq3v5RK267NEPEYw==", "target"=>{"title"=>"Target 2", "description"=>"", "due_date"=>"2018-12-31", "responsible_id"=>"", "team_id"=>""}, "visibility"=>"on", "commit"=>"Create"}

Any ideas?

Hi @Jacob, thank you for your answer. I have 3 models: user, team and member. I'm trying to create a member by using devise_invited, but watching the devise_invited tutorial my app is currently creating a member of a team even if the invited user has not accepted the invitation by email. I wont to create a member only after the confirmation. Otherwise I will have members that do not exist as user. Here a fragment of the code:

Rails.application.routes.draw do
  resources :teams do
    resources :members
  end
  devise_for :users
  root to: 'teams#index'
end
class User < ApplicationRecord
  # Include default devise modules. Others available are:
  # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
  devise :invitable, :database_authenticatable, :registerable,
         :recoverable, :rememberable, :validatables
  has_many :own_teams, class_name: 'Team', foreign_key: :user_id
  has_many :members
  has_many :teams, through: :members
end
class Team < ApplicationRecord
  belongs_to :user
  has_many :members
  has_many :users, through: :members
end
class Member < ApplicationRecord
  belongs_to :user
  belongs_to :team
  attribute :email, :string
  before_validation :set_user_id, if: :email?
  def set_user_id
    self.user =  User.invite!(email: email)
  end
end
class MembersController < ApplicationController
  before_action :authenticate_user!
  before_action :set_team
    def create
      member = @team.members.new(member_params)
      member.team = @team
      if member.save
        redirect_to @team, success: 'Bien hecho'
      else
        redirect_to @team, alert: 'Mal hecho'
      end
    end
    private
      def set_team
        @team = current_user.own_teams.find(params[:team_id])
      end
      def member_params
        params.require(:member).permit(:email)
      end
end

I'm trying to create members of a team by using devise_invitable. But by looking the video related to devise_invitable, I'm not sure if I can create team members ONLY AFTER user confirmation by email. Any ideas?
Thank you