Activity
Thanks a lot for your response. I ended up going with just the inline styles since it was only a few elements that need to be dynamic. I did try to do the sass.erb but it didn't seem to have the same scope(current_account||current_user) and that makes sense now that you mention the sass file will not be updated on every action, and those variables wouldn't make sense to use.
Thanks
I have a multi-tenant app where each tenant can set their primary and accent colors. Is there a way i can grab those values and insert them into a sass file on page load? I"m using rails 5 and postgres if that helps. I have seen some articles but most are many years old.
Thanks
Followed the series on action cable notifications and setup the meta tag so that action would not try to connect if the meta tag was present. Here is my code.
$(document).on("turbolinks:load", function () {
if ($("meta[name='current_user']").length > 0) {
App.activity_feed = App.cable.subscriptions.create("ActivityFeedChannel", {
connected: function() {console.log("I connected")},
disconnected: function() {console.log("I disconnected")},
received: function(data) {
$("#completed-timeline-ul").prepend(data.html);
}
});
};
});
I tried it with and without the turbolinks code as well.. no dice.
I look in the dev tools and see that the meta tag is present and when I run $("meta[name='current_user']").length > 0
in the console it comes back as true.
Not sure what i'm missing. If i get rid of the if statment actioncable connects successfully.
Thanks for the help.
Masud!!! Thanks for this update. I was able to use this to get my action cable working on multi-tenancy... Thanks
Oh Jacob. You are a life saver. So if i put the partials in the same folder as show page and render it like you have above it works. I have to adjust the lookup context to the right folder but it works... It just seems weird that the lookup would do it start at the view folder level and work from there but the partial is starting from the parent folder of the file your in.
I'm trying to use these partials for more than one controller. There has to be a way to have the render partial look outside parent folder for partial right? I was pretty sure you could just add the path from the view folder to where the partial was, but obviously i'm missing something here.
Thanks again for the help.
I'm getting a missing partial error even though my lookup context check comes back as true. My partials is in views/activity_feed/
and is named _appointment_set.html.erb
<% @activities.each do |activity| %>
<% if lookup_context.exists?(activity.action.parameterize.underscore, ["activity_feed"], true) %>
<%= render partial: 'activity_feed/#{activity.action.parameterize.underscore}', locals: {activity: activity} %>
<% end %>
<% end %>
Here is my activity record
[#<Activity id: 1, user_id: 1, contact_id: 1, action: "Appointment Set", activitable_id: 4, activitable_type: "Appointment", created_at: "2017-02-05 02:58:17", updated_at: "2017-02-05 02:58:17">,
Anything jump out to anyone?
Thanks
Yeah, I remember restarting everything, but yes, computers can be fickle.
That is wierd.... Loaded it back up and now it works. Not sure. Maybe a server restart or something I needed to do.
Thanks Chris
Following along with the ActionCable Series.
So in irb when i run the ActionCable.server.broadcast "notifications:4", {html: "<div>Hello</div>"}
it comes back with nil instead of returning 1. Looking in my server logs I see:
NotificationsChannel is transmitting the subscription confirmation
NotificationsChannel is streaming from notifications:4
any idea why that would be returning nil?
Not sure where to look to see error message. redis cli?
Thanks
Posted in SimpleMDE & RedCarpet
Hey Jack. The problem is this. <p></p><p>content goes here</p><p></p>
Notice the extra opening and closing p tags before and after the content p tags.
Posted in SimpleMDE & RedCarpet
So i have set up my forum with simpleMDE and i'm using RedCarpet to parse the markdown. Everything works great except when it parses the markdown, it adds extra set of <p>
tags before and after my post content. Anyone had experience with theses too and might have a clue why this is happening.
Here is the code snippet of the Renderer.
def markdown(content)
@markdown ||= Redcarpet::Markdown.new(Redcarpet::Render::HTML, {
autolink: true,
space_after_headers: true,
fenced_code_blocks: true,
underline: true,
highlight: true,
footnotes: true,
tables: true
})
@markdown.render(content)
end
Thanks
Posted in How do i print out validation error?
Using Rails 5. This is what i had to do to solve my issue. I changed my forum_thread model and added :inverse_of => :forum_thread
on the has_many :forum_posts
class ForumThread < ApplicationRecord
belongs_to :user
has_many :forum_posts, :inverse_of => :forum_thread
accepts_nested_attributes_for :forum_posts
validates :subject, presence: true
validates_associated :forum_posts
end
I found the answer here: http://stackoverflow.com/questions/16782990/rails-how-to-populate-parent-object-id-using-nested-attributes-for-child-obje
Posted in How do i print out validation error?
Hey Brain, this is my forum_thread model file.
class ForumThread < ApplicationRecord
belongs_to :user
has_many :forum_posts
accepts_nested_attributes_for :forum_posts
validates :subject, presence: true
validates_associated :forum_posts
end
Posted in How do i print out validation error?
Just grabbing at straws here. Looking at the forum_thread_params and my server logs.
params.require(:forum_thread).permit(:subject, forum_posts_attributes: [:body])
and what is coming through from the form.
"forum_posts_attributes"=>{"0"=>{"body"=>"asdfasdfasfsdfasfasfasfsf"}}}
wouldn't we need to select the 0 from the object first then ask for the body?
Posted in How do i print out validation error?
So i put that in the forum_thread controller and tried to make a new thread and here is the output I got. Processing by ForumThreadsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"PsBD72jjI/ndjUj1n6+93rigM/f/XgP4iGoOwwFRFIlXSeneTSlkuNP7z9MsshfgRLjELjZN+AEKx28FNw61Aw==", "forum_thread"=>{"subject"=>"this is crazy", "forum_posts_attributes"=>{"0"=>{"body"=>"why is this not saving"}}}, "commit"=>"Create Forum thread"}
User Load (0.8ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT $2 [["id", 3], ["LIMIT", 1]]
**#<ActiveModel::Errors:0x007faeaba473b8 @base=#<ForumThread id: nil, user_id: 3, subject: "this is crazy", created_at: nil, updated_at: nil>, @messages={}, @details={}>**
(0.3ms) BEGIN
User Load (0.8ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT $2 [["id", 3], ["LIMIT", 1]]
(0.4ms) ROLLBACK
Rendering forum_threads/new.html.erb within layouts/application
From the activemodel::errors, I'm not sure what to get from that on why it is not saving.
Any help would be greatlly appreciated.
Thanks
Posted in How do i print out validation error?
So i'm going through building the forum series and whenever i submit the form, it is just re-rendering the new form page. I looked in my server logs and I see that Parameters: {"utf8"=>"✓", "authenticity_token"=>"wMZ+81Viu/9ch0kpqQwij93jbMqL6d2BXTUj6HWsip90ikYj1XVEPTWEE0Z9D7fcFJ4GXhhPdknjWAXIpnrUSQ==", "forum_thread"=>{"subject"=>"adsfas", "forum_posts_attributes"=>{"0"=>{"body"=>"asdfasdf"}}}, "commit"=>"Create Forum thread"}
Is there a way to see the validations error to figure out why this is not saving to the db?
Thanks
Thanks guys.. This clears it up for me!!
Thanks Jacob. So in the example of his autoplay=1
is he hardcoding that onto the end of the url path, or how is that getting added to the params hash?
Thanks
Not sure the correct words to ask the question are. Here is an example from what I have seen: http://www.gorails.com/series/1?old_content=true
So say Chris re-did some of the screencasts,and now he had two versions of the view(content). What is the way like the example url above that you could view the old view(content) by using ?old_content=true
. How would that be set up in routes or would that be in the controller?
I hope this question makes sense.
Thanks for the help.
Edit: I just saw a real example here on gorails where it is saying ?autoplay=1