JM

Joined

4,360 Experience
27 Lessons Completed
0 Questions Solved

Activity

Posted in Adding a New Blog Post Action Discussion

I believe reusability of @blog_post in different methods is due to the scoping rules of instance variables within the class. Each HTTP request is a fresh start, and Rails sets up new instance variables for each request based on the action that handles it.

Also the stateless nature of HTTP means that each request-response cycle is independent. So, the @blog_post variable from a show request won't be remembered in a subsequent new request. Each action sets up its own @blog_post variable, independent of what happened in previous requests.

Need rails 6.1.0 and above to access user.signed_id in case somene is having issues with that

Posted in Incorporating an Admin Dashboard

Hi Dave,

I believe this is what you are looking for https://gorails.com/episodes/using-purchased-themes?autoplay=1

Posted in Our First API (Example) - GoRails

Awesome video Chris, cant wait to dive deeper :) Authentication especially

Posted in dymanic data filter with jquery

Hi Chris I want to replace the create action of my app with dynamic jQuery data pulling so that user has a chance to see the data pulled from the DB before the actual create happens , so currently my create action is then one doing all the dirty work but incase a user abort before updating then a dirty record is saved here it is

  def create
     @attendance_sheet = AttendanceSheet.new(attendance_sheet_params)
     @team = Team.find(attendance_sheet_params[:team_id])
     @team.users.each do |u|
          @attendance_sheet.attendances.build(user: u)
    end

     respond_to do |format|
       if @attendance_sheet.save
        format.html { render :edit }
         format.json { render :show, status: :created, location: @attendance_sheet }
       else
         format.html { render :new }
         format.json { render json: @attendance_sheet.errors, status: :unprocessable_entity }
       end
    end
   end

NB: I am rendering edit to give the user to update the pulled record of user accordingly ..... the attendances records added here are via nested attributes (not sure if it necessary to have that actually)

Now I am some jQuery in the line of :

 $(document).on 'ready page:load', ->
   $('.attendance').hide()
   list = $('.attendance').html() //this is the div to didplay users list from selected team
   $('#attendance_sheet_team_id').change ->

      team = $('#attendance_sheet_team_id :selected').text()

    //here now i wanna match the selected team with it users and show the hidden div with all the users from that team in it , this is the bit where i am stuck .. on how to grab the nested from and query as well 

cheers

Posted in Dynamic select boxes with Rails 4

Hi chris,

The issue is with how the form fields are added , I am using gem cocoon and they have an in built method to help sort that out ..

     cocoon:before-insert: called before inserting a new nested child
     cocoon:after-insert: called after inserting
     cocoon:before-remove: called before removing the nested child
     cocoon:after-remove: called after removal

Posted in Dynamic select boxes with Rails 4

Hey there I am trying out a dynamic select box with rails 4 and I am stuck on where to put the js code because the form exists in a nested form. So should the code go in the js file for the form accepting nested attributes or to the js file named as the partial of the data.

see my partial code below and js as well

_job_queue_fileds.html.erb

     <h4 style="text-align: center">Select Job Queue</h4><br>
           <div id="project_queue_id" class="field">
             <%= f.label :project_name %><br>
             <%= f.collection_select(:project_id, Project.order(:project_name), :id, :project_name, include_blank: true) %>
           </div><br>
           <div id="job_queue_id"class="field">
           <%= f.label :job_name %><br>
             <%= f.grouped_collection_select(:job_id, Project.order(:project_name), :jobs,  :project_name, :id, :job_name, include_blank: true) %>
           </div>

job_queues.js.coffee

  jQuery ->
    jobs = $('#job_queue_id').html()
    $('#project_queue_id').change ->
     project = $('#project_queue_id :selected').text()
       options = $(jobs).filter("optgroup[label='#{project}']").html
     if options
         $('#job_queue_id').html(options)
     else
       $('#job_queue_id').empty()

Will appreciate any pointers, I am not getting any errors but the data is not getting filtered as well

Posted in Nofications screen cast

christophe, thnks for the response but i thought to create a notification in the DB I only need the controller action for Notification.create() as per the tutorial the json part comes much later but for the Notification to be available in the db isnt it only what i have done ?

Posted in Nofications screen cast

Hi Chris ,

I am following the notifications screen here : https://gorails.com/episodes/in-app-navbar-notifications?autoplay=1
all is well no errors but when i create a post the notifications arent being created, any guidance ?

my code can be found here https://github.com/wolfieorama/furry-fortnight

cheers

Posted in lazy high charts gem

Hi there,

I have been tinkering lazy high gem trying to get charts up and running, it works well with hard-coded data into the chart but when I try passing data dynamically i cant make some headway. Here is my code the example on the gems page aren’t helping much i am trying to use raw js for now ....

cheers

Posted in In-App Messages Between Users Discussion

Nice episode Chris , worthy mentioning mailboxer doesnt work with sqlite3 you have to use postgres or mysql

Hi Chris finally made it work with q = Date.strptime(params[:query], '%Y-%m-%d') unless params[:query].blank?

then just passing q to the where clause in the controller .
Thanks Man

Hi Sacko,

Mind posting your params method from the controller for Vente or what the params is actually is when its being pushed to the db

HI Chris , I have hit another block while in my controller i am doing this

        @weekly_performance_reviews = current_admin.weekly_performance_reviews.search('*', where: {  week_start:                      

         Date.new(params[:query], '%Y/%m/%d') })

I am getting an error " no implicit conversion of String into Integer"

cheers man

Hey Chris,

My syntax had an issue i wasn’t using where, thanks man all well now

what i mean is if i am searching for a record dated .. "2016-03-04" and enter "2016-03-05" i still end up with the same results, you know how elastic search corrects the search for you ?

so i was wondering how i can lock the search to an exact match

ok cool..... will check again what i am missing ... or should exact match be more efficient ?

HI Chris,

I implemented elastic search using search kick gem and all went well from search, autocomplete and suggestions when dealing with text.

Now i wanna perform a similar search on table that all columns are dates and integers is it possible .. i have tried tinkering with it but its yielding nothing, any ideas

Posted in Displaying previous score in current record

Hi Chris,

So i finally got a work around to this issue of overwriting the last value on every-record, i wrote a custom method to track the id of the current record and then returns the prev one, this is called directly on the view now. Here it is

      def prev
          self.user.weekly_performance_reviews.where("id < ?", id).last
     end 

with the above now, on the view i can call

                     <%= @weekly_performance_review.prev.kpi_quality_next_target %>

which returns the score of the specific previous record , any other efficient way we can modify this ? so far it works though

Posted in deeply nested forms

Hey Chris i am tinkering with deeply nested forms, all is well but I can manage to render the show with all 3 forms in one ... esp the last form. when its added I get non method error and i am sure the modelling is ok , or isn’t not a hierarchical like this

I can nest B in A and C in B so calling something like @A.B.C should be fairy resolvable. hope this makes sense.