John Munyi


2,650 Experience
10 Lessons Completed
0 Questions Solved


Posted in Nested forms with rows like a table

Yes I have a working nested form.

So I want it to look like a table with heading and also pre load some fields with data

Posted in Nested forms with rows like a table

Hi Chris,

I am battling nested forms , but not your standard .. what I want is a situation where the form behaves like a table where each new row will represent the object from the partial(nested-fields) and if possible populate some data and then i can mass update the other fields.... picture a class register when you can mass update present or absent .....

As a form it works but i dont want to replicate the labels any leads?


Posted in Multiday with calendar gem

cool... wil check it out .. thanks

Posted in Multiday with calendar gem

hey Chris , thanks for the update ... anyother gems you would recommend that would handle that in a simpler mannner ?

Posted in Multiday with calendar gem

Is possible you shed some more light on this ....

which is the best approach in my event.rb i so fat have this

  class Event < ActiveRecord::Base
    belongs_to :user

 def duration
   end_time - start_time

 def event_length(start_time)
   start_time + (duration*24*60*60)  

wondering how to pass on the value returned by event_length to the calendar and have the event displayed across multiple days

settle for activeadmin with device for Authorization and sorcery for the App .. not ideal but got the job done

cool.... i will keep checking on its progress cheers !!

does it support filters at this point ? as activeadmin does ? thats the reason why i was going for active admin .... i needed multiple filters for my data ... May be i should check if they have updated and included that since the last time i checked it out about 3 weeks ago

I already did, but i guess its still to use administrate for a production quality app , isnt ?

I reached out to them, had to chnage a few things but then again activeadmin doesnt support logout links with ids to landed into more problems, i might end up using sorcery for the app and devise for activeadmin ... not ideal but it migth do the job.... Unless there is a way to refactor the sorcery destroy session method not to use an id when deleting a session

HI Chris this seems to work but i get another error:

NoMethodError in Admin::Dashboard#index

Showing /home/jmunyi/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/activeadmin-1.0.0.pre2/app/views/active_admin/page/index.html.arb where line #2 raised:

undefined method `destroy_user_session_path' for


    fyi I am not using Devise anywhere my authorization is being handle by cancancan and sorcery

    When i try navigating to http://localhost:3000/admin i get "This webpage has a redirect loop"
    and also my logs I have

    Started GET "/admin" for at 2015-11-25 17:58:35 +0300
    Processing by Admin::DashboardController#index as HTML
    User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."deleted_at" IS NULL AND "users"."id" = ? LIMIT 1 [["id", 1]]
    Redirected to http://localhost:3000/admin
    Filter chain halted as :authenticate_active_admin_user rendered or redirected
    Completed 302 Found in 4ms (ActiveRecord: 0.1ms)

    I have tried all i can but i am stil stuck :

    my activeadmin.rb looks like this

    def authenticate_admin_user!
    if current_user.admin?
    redirect_to admin_root_path
    redirect_to new_user_session_path

    config.authorization_adapter = ActiveAdmin::CanCanAdapter
    config.authentication_method = :authenticate_admin_user!
    config.current_user_method = :current_user
    config.on_unauthorized_access = :access_denied

    my ability.rb

    def initialize(user)
    user ||=

    if user.admin?
      can :read, ActiveAdmin::Page, :name => "Dashboard"
      can :manage, :all
    elsif user.client?
      can :manage, [Activity, Domain, FactPage, Task, TaskType]
      cannot :read, ActiveAdmin::Page, :name => "Dashboard"
      can :read, Activity
    can :manage, UserSessionsController do |user_session|
      user == user_session
      can :time, Activity
      can :read, ActiveAdmin::Page, :name => "Dashboard"
    can :log_in, User
    can :log_out, User
    can :reset_password, User


    will appreciate some good direction ....

    Hi there I have an app which I need to add active admin dash but already has a model with the same name dashboard.. Will that cause problems in routes?

    Then for now no need..... It's working so I will let it be

    yes Its has worked thanks, dont about the domain , it just explains the context which is needed as for now.

    I am just wondering if there would be a cleaner way to write this line

            td= activity.task.domain.project.code

    A task belongs to a domain and domain belongs to a project , there is no direct association between project and task.....

    Another thing i can point out is i have introduced an activity which belongs to a user and also to a task. This seem to work better they are all associated via ids ..... so now i can record a duration of a user who has worked in different projects and store it even if he moved from one project to another

    but now my next question is how do i display the real name rather than the IDs ? on my view

    Here are my models (User , Project and Task) A user has many projects , a project has many users , A project has many tasks and a tasks belongs to a project , a user has many tasks and a task belongs to user .

    I am using the above to automatically capture time taken per task , the user has to activate a timer when he / she start a start and stops it at the end of task and the time is automatically recorded.....All that is working fine and the time stamps are well recorded.

    The only issue is if i switch a user to a different project (e.g project ABC) even the earlier times recorded under project XYZ get updated to read ABC.... how can i get around that ?

    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

    © 2021 GoRails, LLC. All rights reserved.