Dan Tappin

Joined

8,820 Experience
5 Lessons Completed
9 Questions Solved

Activity

Anyone seeing this not work in Safari? It works in Crome.

Posted in Multitenancy with the Apartment gem Discussion

Anyone got this working with Active Admin?

Posted in Reoccurring events with simple_calendar and ice_cube

I have been chewing on this for a few days. I am thinking about it too much. If I read that link correctly they do it like I was planning. The event belongs to "recurringEventId". I am going to ignore the idea of removing single events, re-scheduling for now. I am going to get it up and running with a minimal feature set and then add those later (if I even need to).

I think I will have Events in one of 5 states:

  • complete
  • active (this is the next event in the queue)
  • cancelled (for some reason you decided to not complete that occurrence)
  • deferred (you still plan to complete it but the system will not remind you until the deferred date)
  • planned (all events after the active one - just placeholder to fill the calendar

The Tasks then have perhaps have 3 states:

  • open (the Events show in the calendar, reminders are sent etc.)
  • paused (not sure on the Event logic here yet)
  • closed (future Events are cleared etc.)

Posted in Using Pundit with ActiveAdmin

New issue posted here:

https://github.com/activeadmin/activeadmin/issues/4264

Have a look at my dummy app:

https://github.com/jasper502/aa_with_pundit_user

Unless I am missing something obvious it's clearly broken.

Posted in Using Pundit with ActiveAdmin

Thanks - I will give that a shot.

Posted in Using Pundit with ActiveAdmin

See my SO post for an update. I found a solution but I would still like to know if this is an isolated issue with my code or an issue with AA / Pundit.

From what I can tell AA is not calling authorize or policy_scope at all. Once you force it to it works (for the most part).

Posted in Using Pundit with ActiveAdmin

I don't know where to start and can't even confirm that it not an issue on my end.

Posted in Using Pundit with ActiveAdmin

On a side note Chris I suspect you have a view bug on the questions home page. Look at this thread. I made the last post but alexander's avatar is shown. Is this the intent? It threw me for a second as I saw my name and someone else face. If the idea is that it's his topic that makes sense but it's a bit confusing in that context.

Posted in Using Pundit with ActiveAdmin

I am not sure if that's the issue. Here is a comprehensive post I just created on this issue:

http://stackoverflow.com/questions/34664645/active-admin-devise-and-pundit-punditpolicyscopingnotperformederror

I think it's a bigger (or simple) issue. My AA policies seem to not being referenced at all. If I say try and load /admin/users Pundit is using the /policies/user_policy.rb file and not /policies/active_admin/user_policy.rb.

In my case (for now) my AA policies are all true until I decide to lock down AA access when I open it up to other users. In the near term it's just me in there so I am the only one to blame if data gets deleted by accident :)

Posted in Using Pundit with ActiveAdmin

Did you ever get this working? I am stuck at the same issue. Can you just disable Pundit for AA entirely?

Posted in Reoccurring events with simple_calendar and ice_cube

I am developing a Rails app that has a Task model. It's like any basic task tracking system where you can set some attributes (name, activity, status, priority etc.) and a due date. For my system I am sticking with just dates but I am actually going to use datetime types to plan for the future if I change my mind.

Simple one-off tasks are easy but most you would want to re-occur. After a lot or Googling in my opinion the best Rails solution is ice_cube (https://github.com/seejohnrun/ice_cube) with recurring_select (https://github.com/GetJobber/recurring_select). recurring_select makes it dead simple to schedule complex repeating events and then use ice_cube to do all the heave lifting for the scheduling.

There are lots of calendars out there but as the name suggests simple_calendar seems to be an obvious choice. With most re-occuring calendars the issue is parsing the events in a time period. There is no really easy way to say find all your Tasks that fall in a window of time (for example a simple_calendar given month). You would end up needing to loop through ALL of your events for a given day and parse out the ones that fall on that day.

Here is my idea - with a given Task when you create up update the task there is a call back that creates / updates an Event that for the most part is a simple model with a Task foreign key and a date. These belong_to Task. There is one drawback I see. You would need to set a limit (say 10 years) to auto-generate Events. It would seem trivial to also be able to set an update_date column based on the schedule that you could use on a nightly rake / sidekiq task to run though an regenerate more future events.

Now you can pass the Events.all or any other ransack search etc. into simple_calendar for display. You can then just call event.task.attribute to get the parent data.

For my system I want to have comments, attachments etc. for completed tasks. When an Event is completed the parent Task is cloned with the original being saved as the read-only record for the last Event and the new cloned Task would be set back to 'active' or some other status and the new Events generated from it. All these Tasks would have some sort of common UUID like the ancestry gem or something like that. You can then see the previous tasks history etc. For example in my case I would be tracking a cost component. You could then see a long term trend in the costs etc.

I want to keep this simple but I see some issues that could make this (and any other system) get ugly fast.

  • re-scheduling future events
  • removing single events
  • changing the parent ice_cube rule and how to handle the two items above

Thoughts / comments / suggestions?

Posted in Deploy Ubuntu 14.04 Trusty Tahr Discussion

Issue also on Stackexchange:

http://stackoverflow.com/qu...

Posted in Deploy Ubuntu 14.04 Trusty Tahr Discussion

Now its:

rake stdout: Nothing written
rake stderr: rake aborted!
NoMethodError: undefined method `tr' for nil:NilClass
/home/deploy/test_deploy/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.4/lib/active_record/connection_adapters/connection_specification.rb:37:in `initialize'

Posted in Deploy Ubuntu 14.04 Trusty Tahr Discussion

I realized that I had not updated my remote database.yml file

Posted in Deploy Ubuntu 14.04 Trusty Tahr Discussion

The Java runtime needs to be noted also. I am stuck here in the deploy stage:

Psych::BadAlias: Cannot load `Rails.application.database_configuration`:
Unknown alias: default

Google results in lots of comments about your default section of your database file. I took those right out and hard coded them vs the alias and I still get this error.

Exactly - the more I think about it postgeSQL schemas or the apartment gem are a great way to segregate data but create a lot of work.

Here is a related StackExchange post of mine to consider:

http://stackoverflow.com/questions/28513849/rolify-and-acts-as-tenant-with-single-signon-with-some-devise-pundit-on-the-s

Any thoughts on acts_as_tenant vs. apartment?

The multiple database per tenant seems bulletproof but would get ugly with lots of tenants. The odds of something going wrong with migrations etc. does not seem worth the risk.

acts_as_tenant seems to implement the system I was going to anyway.

I think I figured it out. I stumbled across this:

https://gist.github.com/6dd44fc841e80bbc2265.git

I switched my routes to "user/..." from "devise/..." and that seemed to do the trick.

Hmmm... took my routes and tried this for fun:

devise_for :users, :skip => [:sessions], :controllers => { :registrations => 'users/registrations', :sessions => 'users/sessions' }
as :user do
get '/signin' => 'devise/sessions#new', :as => :new_user_session
post '/signin' => 'devise/sessions#create', :as => :user_session
delete '/signout' => 'devise/sessions#destroy', :as => :destroy_user_session
end

I wanted to see if the normal Devise routes work and they do except that now the validation fails completely. If I submit a blank form I get all kinds of errors but if I fill it out it works fine now. I am getting close but obviously missing something small here.

I have posted a few related questions on this but now I am at a road block. I had this system working quite well and then I went to add to it and now I broke it real good!

First off I just discovered Gist so here is my code:

https://gist.github.com/jasper502/065a63fde266fac1fbf5

The idea here is that I have a single User login that can eventually be tied to multiple Companies via the Role.

You signup via Devise on the custom /register route and fill out the Company information etc. The custom registration controller creates the Role during the user creation and sets a few other attributes.

When I try to create a new user / company the additional user fields (name_first & name_last) always fail validation regardless if they are in fact valid. The nested Company fields do not validate at all. If I enter the email and password field only the form works but only creates the User record.

To me it seems like the custom registration controller is not being processed at all because it seems to not want to allow my additional params specified in sign_up_params

logo Created with Sketch.

Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more. Icons by Icons8

© 2022 GoRails, LLC. All rights reserved.